mySQL子查询返回多行的处理
以下是我的例子:mySQL子查询返回多行的处理,mysql,Mysql,以下是我的例子: select row_x from table_1 where row_y = (select row_a from table_2 where row_b = x) 我遇到的问题是,如果子查询返回多行,我的查询需要返回多行 理想情况下,它将转化为类似于: 'select row_x from table_1 where row_y = '<first row from subquery>' or row_y = '<second row from sub
select row_x from table_1 where row_y = (select row_a from table_2 where row_b = x)
我遇到的问题是,如果子查询返回多行,我的查询需要返回多行
理想情况下,它将转化为类似于:
'select row_x from table_1 where row_y = '<first row from subquery>' or row_y = '<second row from subquery>' etc.
'从表_1中选择行_x,其中行_y=''或行_y=''等。
我怎样才能做到这一点?谢谢 您要在子句中查找
select row_x from table_1
where row_y
IN (
select row_a from table_2 where row_b = x
)
如果您在(子查询)中执行
第y行怎么办?我相信这会更有效。
SELECT t1.row_x FROM table_1 t1 JOIN table_2 t2 ON t1.row_y=t2.row_a WHERE t2.row_b = x