账单表
Bill_date Total
28/10/13 10000
27/10/13 5000
付款表
Paid_on amount
28/10/13 5000
30/10/13 10000
预期输出
date Credit debit
27/10/13 5000
28/10/13 10000 5000
30/10/13 10000
最佳答案
试试这个
SELECT t1.bill_date, t1.total as Credit, t2.total as debit FROM Bills t1
LEFT JOIN Payments t2 ON t1.bill_date= t2.bill_date
UNION
SELECT t2.bill_date, t1.total as Credit, t2.total as debit FROM Bills t1
RIGHT JOIN Payments t2 ON t1.bill_date= t2.bill_date
关于mysql - 如何编写查询以在我的 sql 中获取如下所示的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19628922/