简体   繁体   English

什么是 MS Access SQL 相当于 FULL OUTER JOIN 与 a.key 是 NULL 和 b.key 是 NULL

[英]What is the MS Access SQL equivalent of FULL OUTER JOIN with a.key IS NULL and b.key IS NULL

Example Query that I want to execute in MS Access SQL:我想在 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

Since MS Access SQL does not allow FULL OUTER JOIN, I tried using the code below but the results aren't right.由于 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

Does anyone know how to construct the MS Access SQL equivalent of the Example Query above that I'm trying to execute?有谁知道如何构建我试图执行的上面示例查询的 MS Access SQL 等效项?

Use:利用:

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);

The . . . . . . . . . is for the columns that you want.用于您想要的列。

You could use * if you used:你可以使用*如果你使用:

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM