簡體   English   中英

MY SQL Sub 查詢返回超過 1 行

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM