我使用sql服务器。我想合并两个表。说我有 2 张桌子
表格1
id | item_id | item_name | load_qty
1 1 YRD 3
2 1 YRD 4
3 2 SS 2
4 2 SS 3
5 3 SS 7
表2
id | item_id | delivery_arrive | recevie_qty
1 1 2019-08-22 11:38:36.6820000 2
2 1 2019-08-23 11:38:36.6820000 3
3 2 2019-08-22 11:38:36.6820000 1
我的预期结果是
id | item_id | item_name | load_qty | delivery_arrive |recevie_qty
1 1 YRD 3 2019-08-22 11:38:36.6820000 2
2 1 YRD 4 2019-08-23 11:38:36.6820000 3
3 2 SS 2 2019-08-22 11:38:36.6820000 1
4 2 SS 3
5 3 SS 7
SELECT t1.*, t2.delivery_arrive, t2.recevie_qty
FROM table1 as t1
LEFT JOIN table2 as t2 ON t1.Id = t2.Id
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句