[英]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.