我想把两张不同栏的桌子连在一起:
Table 1: Table 2:
Name Region Price_2018 Cost_2018 Name Region Price_2017 Cost_2017
----------------------------------- ---------------------------------
A US 12 32 A US 30 56
B CH 20 15 D JP 45 20
C EU 30 16 B CH 60 30结果表将是
Name Region Price_2018 Cost_2018 Price_2017 Cost_2017
-------------------------------------------------------
A US 12 32 30 56
B CH 20 15 60 30
C EU 30 16 null null
D JP null null 45 20 提前感谢
发布于 2018-10-18 15:39:50
您需要full outer join:
select coalesce(t1.name, t2.name), coalesce(t1.Region, t2.Region),
t1.Price_2018, t1.Cost_2018, t2.Price_2017, t2.Cost_2017
from table1 t1 full outer join
table2 t2
on t2.name = t1.name;https://stackoverflow.com/questions/52877645
复制相似问题