【发布时间】:2016-05-21 08:40:32
【问题描述】:
我有 2 张桌子,分别称为 tb_compulsory_savings 和 tb_time_deposits
为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中不存在,则显示为null。
我已经尝试了 LEFT JOIN、RIGHT JOIN、UNION 但仍然显示不符合我的要求。
【问题讨论】:
-
再次尝试左连接。向我们展示你的最大努力