我有以下表格
表A
ID "Other Columns"
1
2
3
表 B
ID "Other Columns"
3
4
5
返回以下结果的有效方法是什么?
结果
ID "Other Columns"
1
2
4
5
最佳答案
完整的外连接应该可以工作,并且只能通过每个表一次。它们可能很棘手,所以请仔细测试!
SELECT
isnull(A.ID, B.ID) ID
,"Other columns" -- Handle nulls properly!
from TableA A
full outer joing TableB B
on B.ID = A.ID
where not (A.ID is not null
and B.ID is not null)
关于sql - SQL中的异或联接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39777908/