我的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
在这我得到错误
错误] 1242 - 子查询返回超过1行
有没有其他方法可以执行相同的功能?
答案 0 :(得分:0)
您的内部查询返回的值超过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