[英]Fetching multiple rows from Sub Query in MySql
我正在尝试执行此查询
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`
谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.