0
有問題要問。當我使用左連接時,即使某行有空值時,我如何列出所有左表以顯示數據?選擇MySQL月份()爲空列
繼承人我查詢:
SELECT *, SUM(transactions.debit_credit) current_spending
FROM (`budget`) LEFT JOIN `categories` ON `budget`.`category`=`categories`.`idcategory`
LEFT JOIN `user_category` ON `budget`.`category`=`user_category`.`idcategory`
LEFT JOIN `category_transaction` ON `budget`.`category`=`category_transaction`.`idcategory`
LEFT JOIN `transactions` ON `category_transaction`.`idtransaction`=`transactions`.`idtransaction`
WHERE `user_category`.`iduser` = '1'
AND MONTH(transactions.transaction_date) = '11'
GROUP BY `budget`.`idbudget`;
當我刪除AND MONTH(transactions.transaction_date) = '11'
的查詢工作正常接受它顯示的所有數據,而不只是1個月交易。
幫助??請??任何想法如何?
注意transaction.transaction_date在TIMESTAMP數據類型 – kamudrikah