[英]mysql error: sub-query returns more than 1 row
我在這里使用兩個表projections_report p
和access_rights a
。 我不知道為什么我得到錯誤:
子查詢返回多行
(case when paramChannel='AllC' then p.gl_sal_chan in
(case when dc_lob=0 then (select distinct pr.gl_sal_chan from
projections_report pr) else (select distinct pr1.gl_sal_chan
from projections_report pr1 where pr1.gl_sal_chan
in (select distinct a.gl_sal_chan from access_rights
a where a.userid= paramUserId)) end)
else p.gl_sal_chan = paramChannel end)
我嘗試使用所有關鍵字。 請幫忙。
提前致謝。
我試圖用另一種方式來做到這一點,並做到了正確。 首先我將第二種情況陳述的其他情況下的陳述改為
(select distinct gl_sal_chan from access_rights where userid = paramUserid)
因為兩者都返回相同的結果(我不好),其次我將整個條件更改為
(case when (paramChannel = 'AllC' && dc_lob = 0) then '%' = '%' else
(case when (paramChannel='AllC' && dc_lob != 0) then
gl_sal_chan in (select distinct gl_sal_chan from access_rights where userid = paramUserid)
else gl_sal_chan= paramChannel end)end)
無論如何,謝謝@all :)
在使用子查詢時,在子查詢中使用LIMIT僅返回一條記錄,它可能返回多個記錄
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.