[英]MySQL Error : Subquery returns more than 1 row
Getting error : #1242 - Subquery returns more than 1 row
得到错误: #1242 - Subquery returns more than 1 row
while executing this 在执行此
SELECT `Index` , `FundName` ,Count(*),
(SELECT COALESCE(sum(b.PricePerWeek),0)
FROM tbl_FundSubscriptions
WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= SubscribeDt
GROUP BY FundIDSend)
FROM tbl_FundSubscriptions b, tbl_FundStatic a
WHERE a.FundID = b.FundIDSend
AND FundIDSend IN
(SELECT FundID
FROM tbl_FundStatic
WHERE UserID = '14')
GROUP BY a.FundName,a.Index
What could be wrong? 有什么事吗
Thanks 谢谢
Your subquery is returning more then 1 row. 您的子查询返回的行数超过1。
Either you LIMIT
the subquery to one row or you LEFT JOIN
it with the other table. 您可以将子查询LIMIT
为一行,也可以将其与另一表LEFT JOIN
。
Is this the query you're looking for? 这是您要查找的查询吗? Not knowing your table structure, we'll never know, but this does what your query appears to have been indented to do. 不知道您的表结构,我们永远不会知道,但是这样做确实可以使您的查询看上去可以缩进。 (Does that make any sense at all?) (这有任何意义吗?)
SELECT `Index`, `FundName`, COUNT(*),
(SELECT SUM(`PricePerWeek`)
FROM `tbl_FundSubscriptions`
WHERE DATE_SUB(CURDATE(),INTERVAL 7 DAY) <= `SubscribeDt`
AND `FundIDSend` = `tbl_FundStatic`.`FundID`)
FROM `tbl_FundStatic`
WHERE `UserID` = '14'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.