2016-12-26 31 views
0

我需要連接兩個表。加入兩個帶有混合列的表oracle

表1

Columns A, B, C 
Row 1 10, 20, 30 
Row 2 40, 50, 60 

表2

Columns A, B, D 
Row 1 70, 80, 90 
Row 2 5, 6, 7 

加入

Output should be 
Columns A, B, C, D 
Row 1 10, 20, 30, null 
Row 2 40, 50, 60, null 
Row 3 70, 80, null, 90 
Row 4 5, 6, null, 7 
+0

問題是非常不清楚。請添加更多信息 – GurV

+0

我認爲所以你需要這個..'select table1.a,table1.b.table1.c,table2.d from table1 inner join table2 on table1.a = table2.a and table1.b = table2。 b' –

回答

0

你只需要一個UNION ALL

select a, b, c, null d from table1 
union all 
select a, b, null, d from table2 
+1

感謝Gurwinder – NItin

0

後嘗試。這個問題有很多答案,但我認爲這是最適合這種情況:

select a, b, c, null as d 
    from table1 
    union all 
    select a, b, null as c, d 
    from table2;