我有兩個表格,一個用於下載,一個用於上傳。它們幾乎完全相同,但是與其他一些列有所不同。我想爲表格中每個項目的每個日期生成一個統計列表。如何將這兩個查詢合併爲一個?
我使用這兩個查詢,但必須在運行它們後在php中合併數據。我希望在單個查詢中運行它們,它將返回按日期分組的每個行中的兩個查詢中的列。有時沒有任何下載數據,只有上傳數據,並且在我之前的所有嘗試中,如果它無法從兩行中找到日誌數據,它將跳過該行。
我該如何將這兩個查詢合併爲一個,哪裏可以顯示數據,即使它只在一個表中可用?
SELECT DATE(upload_date_added) as upload_date, SUM(upload_size) as upload_traffic, SUM(upload_files) as upload_files
FROM packages_uploads
WHERE upload_date_added BETWEEN '2011-10-26' AND '2011-11-16'
GROUP BY upload_date
ORDER BY upload_date DESC
SELECT DATE(download_date_added) as download_date, SUM(download_size) as download_traffic, SUM(download_files) as download_files
FROM packages_downloads
WHERE download_date_added BETWEEN '2011-10-26' AND '2011-11-16'
GROUP BY download_date
ORDER BY download_date DESC
我希望得到這樣的結果行:
日期,upload_traffic,upload_files,download_traffic,download_files
所有幫助感激!