[英]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.