我有2個SQL Oracle數據表。如何連接兩個表
A: Col1 | Col2 | Key
c1 c2 1
c3 c4 2
c5 c6 3
B: Co1 | Co2 | Key
a1 a2 2
a3 a4 3
我需要選擇讓我下表:
C:
a1 a2 c3 c4
a3 a4 c5 c6
- - c1 c2
我怎樣才能用SQL做呢?正常加入:
select * from a, b where a.key = b.key;
沒有給出預期的結果。
謝謝!我會測試它,然後接受。 – Tony
完美的作品。 http://sqlfiddle.com/#!4/2aa79/4/0當你想從左側的對象中獲得所有的東西時,使用'left outer join'即使沒有任何與右側對象相關的東西(左邊的外連接) –