gpt4 book ai didi

mysql - 更新表中的行时出错

转载 作者:行者123 更新时间:2023-11-29 06:15:28 24 4
gpt4 key购买 nike

我在更新行时遇到错误“SQLCODE: -811”。我知道错误是由于我的内部查询返回了多个值。我需要知道如何正确关联查询。请帮我查询!

update hpl.kamodt C
set (NRANK, chghlightacces) =
(select NRANK, chghlightacces
from hpl.kamodt as A
inner join (
select naccesgrpref, NMOD, count(*)
from hpl.kamodt
where naccesgrpref is not null
and NMOD is not null
group by naccesgrpref, NMOD
having count(naccesgrpref) > 1) B
on A.naccesgrpref = B.naccesgrpref
and A.NMOD = B.NMOD
and A.naccesgrpref = A.NACCES)

内部查询正在检查具有组的值并为这些列选择排名、accesgrpref。我必须为其 naccesgrpref 等于来自 innerquery 的 naccesgrpref 值的部分设置这些值。

请帮我查询一下。

最佳答案

据推测,您的意图是这样的:

update hpl.kamodt C
set (NRANK, chghlightacces) =
(select NRANK, chghlightacces
from (select naccesgrpref, NMOD, count(*)
from hpl.kamodt
where naccesgrpref is not null and NMOD is not null
group by naccesgrpref, NMOD
having count(naccesgrpref) > 1
) B
where C.naccesgrpref = B.naccesgrpref and
C.NMOD = B.NMOD
)
where C.naccesgrpref = C.NACCES;

这是(智能)推测。相关子查询应该引用外部查询中的表。您的版本没有关联,因此它返回重复项这一事实不足为奇。

关于mysql - 更新表中的行时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36132966/

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