drew22
asked on
WHERE ...IN () using concat()
Trying to find out what records from legacy.f_group exist in survey.participant.
This works:
SELECT con_id, lastname
FROM legacy.f_group
WHERE lastname
IN (
SELECT lastname
FROM survey.participant
)
...but when I try to narrow it down using 2 cols, I get an error:
SELECT con_id, concat (lastname,zip) AS namezip
FROM legacy.f_group
WHERE namezip
IN (
SELECT concat (lastname,zip) AS namezip
FROM survey.participant
)
#1054 - Unknown column 'namezip' in 'scalar IN/ALL/ANY subquery'
drew
This works:
SELECT con_id, lastname
FROM legacy.f_group
WHERE lastname
IN (
SELECT lastname
FROM survey.participant
)
...but when I try to narrow it down using 2 cols, I get an error:
SELECT con_id, concat (lastname,zip) AS namezip
FROM legacy.f_group
WHERE namezip
IN (
SELECT concat (lastname,zip) AS namezip
FROM survey.participant
)
#1054 - Unknown column 'namezip' in 'scalar IN/ALL/ANY subquery'
drew
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can use an alias to refer to a column in GROUP BY, ORDER BY, or HAVING clauses.