我有2代表的旁边列,被称为tb_compulsory_savings
和tb_time_deposits
MySQL查询2表加入
为tb_compulsory_savings
form_no | badge_id | compulsory_savings | transaction_date
1 | 090802 | 50000 | 2016-05-20 13:10:11
2 | 090801 | 50000 | 2016-05-20 13:15:15
为tb_time_deposits
form_no | badge_id | time_deposits | transaction_date | period | status
1 | 090802 | 100000 | 2016-05-20 13:20:44 | May-2016 | closed
现在我想查询该2表像这样:
badge_id | compulsory_savings | time_deposits
090802 | 50000 | 100000
090801 | 50000 | null
因此,如果badge_id: 090801
在tb_time_deposits
中不存在,则它将显示为空。
我试过左加入,右加入,但仍然显示不是我想要的。
再次尝试左联接。向我们展示您的最佳努力 – Strawberry