I have 3 tables like this:
table1
x
ID Date Number City
--------------------------------
1 18.11.2019 345 Bristol
table2
ID Date Type Code
-------------------------------
3 18.11.2019 returned 11
table3
ID Date Source Product
----------------------------------
39 18.11.2019 unknown shirt
I would like to write a query that shows a result for the same date on all three tables.
Desired result:
Date table1_Number table1_City table2_Type table2_Code table3_Source table3_Product
18.11.2019 345 Bristol returned 11 unknown shirt
Advertisement
Answer
Are you looking for simple joins, as follows?
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