sql-server - 在 sql server 上合并 2 个单元格
问题描述
我使用 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
推荐阅读
- android - 无法为 UVCCamera(Android USB 相机)设置 Gamma 和 Hue
- sql - SQL - 从两个表创建列 - 一个数组 int 列和字符串表 - 匹配转换
- sed - 使用 silver searcher 和 sed 查找和替换文件中的文本
- reactjs - Storybook 不理解 antd 组件的按需导入
- python - 使用 asyncio.wait 在任务异常后重试任务
- css - 如何设置子菜单中文本的悬停颜色?
- reactjs - 使用传递的值测试组件方法的返回值
- r - 使用推文绘制时间线失败
- c# - 循环遍历特定文件夹中的所有文件,并将文件名插入 Excel 中特定单元格的位置
- linux - bash 脚本循环中断