假設我有以下2個表:SQL服務器加入失蹤NULL值
Table1: Table2:
Col1: Col2: Col3: Col1: Col2: Col4:
a b c a b d
e <null> f e <null> g
h i j h i k
l <null> m l <null> n
o <null> p o <null> q
現在,我想加入上Col1
和Col2
這些表,並帶回整套的樣子:
Result:
Col1: Col2: Col3: Col4:
a b c d
e <null> f g
h i j k
l <null> m n
o <null> p q
於是,我試着像SQL:
SELECT Table1.Col1, Table1.Col2, Table1.Col3, Table2.Col4
FROM Table1 INNER JOIN Table2
ON Table1.Col1 = Table2.Col1
AND Table1.Col2 = Table2.Col2
但它不匹配日ËNULL
在Col2
值,所以我結束了:
Result:
Col1: Col2: Col3: Col4:
a b c d
h i j k
我怎樣才能得到我要尋找的結果?
謝謝!
喜@戈登 - linoff,你的答案是最珍貴的在這種情況下。非常感謝 –