Reputation: 2937
Here is my example:
select row_x from table_1 where row_y = (select row_a from table_2 where row_b = x)
The problem that I am running into is that my query needs to return multiple rows if the subquery returns multiple rows.
Ideally it would translate to something similar to:
'select row_x from table_1 where row_y = '<first row from subquery>' or row_y = '<second row from subquery>' etc.
How can I make this happen? Thanks!
Upvotes: 7
Views: 18358
Reputation: 12356
SELECT t1.row_x FROM table_1 t1 JOIN table_2 t2 ON t1.row_y=t2.row_a WHERE t2.row_b = x
Upvotes: 3
Reputation: 86336
You are looking for IN clause
select row_x from table_1
where row_y
IN (
select row_a from table_2 where row_b = x
)
Upvotes: 16