mysql 错误:子查询返回超过 1 行 [英] mysql error: sub-query returns more than 1 row

查看:87
本文介绍了mysql 错误:子查询返回超过 1 行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里使用了两个表 projections_report paccess_rights a.我不知道为什么我收到错误:

I am using two tables here projections_report p and access_rights a. I can't find out why I am getting the error:

子查询返回多于一行

(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)

我尝试使用所有关键字.请帮忙.

I tried using all and any keywords. Please help.

提前致谢.

推荐答案

我尝试用另一种方式来做,但它做对了.首先,我将第二个 case 语句的 else 条件中的语句更改为

I tried to do it in another way and got it right. Firstly I changed the statement in else condition of second case statement to

(select distinct gl_sal_chan from access_rights where userid = paramUserid)

因为两者都返回相同的结果(我的错误),其次我将整个条件更改为

as both return the same result(my bad) and secondly I changed the entire condition to

(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 :)

Anyway Thanks @all :)

这篇关于mysql 错误:子查询返回超过 1 行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆