[英]MY SQL Sub query returns more than 1 row
我的 SQL--->
insert into table b (col list)
select id,
Col2 = ( select col from table B where col5 = 'true'),
Col3 = ( select col from table B where col4 = 'true')
from table a
在这我收到错误
Err] 1242 - 子查询返回超过 1 行
有没有其他方法可以实现相同的功能?
您的内部查询返回了 1 个以上的值。 这将起作用,因为我已将内部查询结果限制为 1,但我不确定您的要求是否得到满足。
insert into table b (col list)
select id,
Col2 = ( select col from (select col from table B where col5 = 'true' limit 0,1) as alias ),
Col3 = ( select col from (select col from table B where col4 = 'true' limit 0,1) as alias 2)
from table a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.