0
如何完成這個完整的外連接?如何在可能的空鍵上執行完整的外連接?
注意:我問的不是我的original post。
TABLE1
+----+-----------+-----------+---------+
| ID | FILTER1 | FILTER2 | DATA1 |
| 1 | NULL | filter2-A | data1-A |
| 2 | filter1-B | filter2-B | data1-B |
| 3 | filter1-C | filter2-C | data1-C |
| 3 | filter1-D | filter2-D | data1-D |
+----+-----------+-----------+---------+
TABLE2
+----+-----------+-----------+---------+
| ID | FILTER1 | FILTER2 | DATA2 |
| 1 | filter1-A | filter2-A | data2-A |
| 2 | filter1-B | filter2-B | data2-B |
| 3 | filter1-C | filter2-C | data2-C |
| 3 | filter1-D | filter2-D | data2-D |
+----+-----------+-----------+---------+
結果
+------------+-----------+---------+---------+
| FILTER1 | FILTER2 | DATA1 | DATA2 |
| NULL | filter2-A | data1-A | NULL |
| filter1-A | filter2-A | NULL | data2-A |
| filter1-B | filter2-B | data1-B | data2-B |
| filter1-C | filter2-C | data1-C | data2-C |
| filter1-D | filter2-D | data1-D | data2-D |
+------------+-----------+---------+---------+
有些擔憂:
兩個表實際上分享5個FIL ter字段,我必須對結果進行一些過濾,這意味着我需要參考過濾字段。而且我不想在很多地方撥打非常詳細的COALESCE()
或ISNULL()
。任何方式避免這種情況,而不訴諸於子查詢?
這是我真正的第一個念頭。謝謝 – mattalxndr