开发者

MySQL Error : Subquery returns more than 1 row

开发者 https://www.devze.com 2023-02-10 04:16 出处:网络
Getting error : #1242 - Subquery returns more than 1 row while executing this SELECT `Index` , `FundName` ,Count(*),

Getting error : #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


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'


Your subquery is returning more then 1 row.

Either you LIMIT the subquery to one row or you LEFT JOIN it with the other table.

0

精彩评论

暂无评论...
验证码 换一张
取 消