我正在尝试执行此查询

SELECT R1.`report_date`,(SELECT R2.`report_id` FROM `reports` AS R2 WHERE R2.`report_date` = R1.`report_date`) AS DATA FROM `reports` AS R1 GROUP BY R1.`report_date`


我收到此错误

MySQL said:

#1242 - Subquery returns more than 1 row


如何从该查询中获取多行?

最佳答案

我认为这些SQL对您有用。

SELECT R1.`report_date`,R2.`report_id` AS DATA
FROM `reports` AS R1 ,`reports` AS R2
WHERE R2.`report_date` = R1.`report_date`
GROUP BY R1.`report_date`


你可以尝试这些SQL吗

 SELECT R1.`report_date`,R2.`report_id` AS DATA
    FROM `reports` AS R1 ,`reports` AS R2
    WHERE R2.`report_date` = R1.`report_date`
    GROUP BY R2.`report_id`, R1.`report_date`


谢谢。

关于php - 从MySql中的子查询中获取多行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30953398/

10-12 14:17