gpt4 book ai didi

Mysql错误: Subquery returns more than 1 row

转载 作者:行者123 更新时间:2023-11-29 14:32:42 25 4
gpt4 key购买 nike

嗨,我有一个 mysql 查询来获取一些 id(studentID),如下所示

select t1.studentID 
from remittedfees t1
where (select t2.fees
from feesasigned t2
where t2.studentID=t1.studentID) = (select sum(t3.remittedAmt)
from remittedfees t3
where t3.studentID = t1.studentID);

但查询返回以下错误

  ERROR 1242 (21000): Subquery returns more than 1 row

如何重写查询以获得结果?

最佳答案

试试这个[更新]:

SELECT t2.studentID 
from feesasigned t2
INNER JOIN (
SELECT t3.studentID, SUM(t3.remittedAmt) FeeSum
FROM remittedfees t3
GROUP BY t3.studentID) v ON t2.studentID = v.studentID and t2.fees = v.FeeSum

关于Mysql错误: Subquery returns more than 1 row,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9714392/

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