gpt4 book ai didi

SQL 查询 "Subquery returned more than 1 value"

转载 作者:行者123 更新时间:2023-12-04 01:59:15 25 4
gpt4 key购买 nike

我已尝试从应用程序修改 SQL 查询但无法使其正常工作

错误:

"Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression."

原始查询:

SELECT fycode, fyname, class3, '', '', '', defje, zjm, '', ''
FROM zy_fy

UNION ALL
SELECT Ypcode, Ypname,
(SELECT a.lbname FROM YK_yplb a where a.lbid = b.yplb)
, gg, sldw, '', '', '', '', ''
FROM YK_ypzd b

UNION ALL
SELECT FYID, NAME, DYKS+'-'+CLASS2, '', '次', '', FYMONEY, ZJM, ZJM1, ''
FROM mz_fy

修改后的查询:

SELECT fycode, fyname, class3, '', '', '', defje, zjm, '', ''
FROM zy_fy

UNION ALL
SELECT Ypcode, Ypname,
(select a.lbname from YK_yplb a where a.lbid = b.yplb)
,gg,sldw, '',
(select c.dj from YK_kc c where c.Ypcode = b.Ypcode)
,'','',''
FROM YK_ypzd b

UNION ALL
SELECT FYID, NAME, DYKS+'-'+CLASS2, '', '次', '', FYMONEY, ZJM, ZJM1, ''
FROM mz_fy

我刚刚在第 3 个 select 语句的第 7 列中插入了一个子查询

谢谢!

最佳答案

    select fycode,fyname,class3,'','','',defje,zjm,'',''  from zy_fy union all
select Ypcode, Ypname,(select a.lbname from YK_yplb a where a.lbid =
b.yplb limit 1),gg,sldw,'',(select c.dj from YK_kc c where c.Ypcode =
b.Ypcode),'','','' from YK_ypzd b union all select FYID,NAME,DYKS+'-
+CLASS2,'','次','',FYMONEY,ZJM,ZJM1,'' from mz_fy

使用限制

关于SQL 查询 "Subquery returned more than 1 value",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48503110/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com