MY 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
in this i am getting error
Err] 1242 - Sub query returns more than 1 row
is there any another method to do the same functionality?
You inner queries are returning more than 1 values. This will work since I have limited the inner query result to 1 but I am not sure whether your requirements are satisfied or not.
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.