[英]What is the MS Access SQL equivalent of FULL OUTER JOIN with a.key IS NULL and b.key IS NULL
我想在 MS Access SQL 中執行的示例查詢:
SELECT *
FROM TableA AS a
FULL OUTER JOIN TableB AS b
ON a.key = b.key
WHERE a.key IS NULL
OR b.key IS NULL
由於 MS Access SQL 不允許 FULL OUTER JOIN,我嘗試使用下面的代碼,但結果不正確。
SELECT *
FROM (TableA AS a
LEFT JOIN TableB AS b
ON a.key = b.key)
RIGHT JOIN TableB AS c
ON a.key = c.key
WHERE b.key IS NULL
OR a.key IS NULL
有誰知道如何構建我試圖執行的上面示例查詢的 MS Access SQL 等效項?
利用:
select . . .
from a
where not exists (select 1 from b where b.key = a.key)
union all
select . . .
from b
where not exists (select 1 from a where a.key = b.key);
. . .
. . .
用於您想要的列。
你可以使用*
如果你使用:
select a.*, b.*
from a left join
b
on 1 = 0
where not exists (select 1 from b where b.key = a.key)
union all
select a.*, b.*
from b left join
a
on 1 = 0
where not exists (select 1 from a where a.key = b.key);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.