sql - 将 3 个具有相同日期的表的结果连接起来
问题描述
我有3个这样的表:
表格1
ID Date Number City
--------------------------------
1 18.11.2019 345 Bristol
表2
ID Date Type Code
-------------------------------
3 18.11.2019 returned 11
表3
ID Date Source Product
----------------------------------
39 18.11.2019 unknown shirt
我想编写一个查询,在所有三个表上显示同一日期的结果。
期望的结果:
Date table1_Number table1_City table2_Type table2_Code table3_Source table3_Product
18.11.2019 345 Bristol returned 11 unknown shirt
解决方案
您是否正在寻找简单的连接,如下所示?
select
t1.number table1_number,
t1.city table1_city,
t2.type table2_type,
t2.code table2_code,
t3.source table3_source,
t3.product table3_product
from table1 t1
inner join table2 t2 on t1.date = t.date
inner join table3 t3 on t3.date = t.date
推荐阅读
- python - 如何在子类中使用关键字参数而不是调用超类的方法
- javascript - 为什么 reactjs 中的箭头函数有时被视为组件?
- python - Tkinter - 您可以将整个对象存储在树视图元素的值中吗?
- flutter - 崩溃报告。你能帮我解决这个崩溃吗?
- javascript - 错误:将循环结构转换为 json。从 salesforce 收到的带有访问令牌的数据
- arrays - 如何将mongodb行聚合到列
- python-3.x - 将 ActionScript3 的 ByteArray uncompress() 转换为 Python 3
- kubernetes - 由于证书 mTLS 上的路径无效,Istio Sidecar 代理无法启动
- javascript - 使用 ajax 编辑时未定义的值
- html - CSS/Bootstrap 粘性滚动效果