模拟FULL OUTER JOIN:LEFT + RIGHT JOIN的UNION与交叉连接的性能

时间:2018-05-11 06:24:20

标签: sql ms-access outer-join jet

Access / Jet数据库引擎不支持FULL OUTER JOIN s:

SELECT Table1.*, Table2.*
FROM Table1
FULL OUTER JOIN Table2 ON Table1.JoinField = Table2.JoinField

通常建议的替代方法是UNION LEFTRIGH JOIN s的结果;以下内容有所不同:

SELECT Table1.*, Table2.*
FROM Table1
LEFT JOIN Table2 ON Table1.JoinField = Table2.JoinField

UNION ALL 
SELECT Table1.*, Table2.*
FROM Table1
RIGHT JOIN Table2 ON Table1.JoinField = Table2.JoinField
WHERE Table1.JoinField IS NULL

但是,是否也可以使用交叉连接?

SELECT Table1.*, Table2.*
FROM Table1, Table2
WHERE Table1.JoinField = Table2.JoinField
    OR Table1.JoinField IS NULL
    OR Table2.JoinField IS NULL

以这种方式使用交叉联接是否有任何性能损失或其他缺点?

0 个答案:

没有答案