简体   繁体   English

MS-Access SQL:不支持连接表达式

[英]MS-Access SQL : Join expression not supported

I have 2 tables A and B. I want to create a third one, C. C must contain each record that is in A but not in B, and each record that is in A and B. 我有2个表A和B.我想创建第三个,C。C必须包含A中但不在B中的每个记录,以及A和B中的每个记录。

I've tried the following : 我尝试过以下方法:

SELECT A.* INTO C FROM (A INNER JOIN B ON A.Id = B.Id) LEFT JOIN B ON A.Id = B.Id WHERE B.Id IS NULL;

But it gives me the error message : JOIN expression not supported. 但它给我错误消息: JOIN expression not supported.

When there's only the INNER JOIN or the LEFT JOIN , it works perfectly. 只有INNER JOINLEFT JOIN ,它才能完美运行。 But for some reason when I combine both with the brackets, it doesn't work. 但由于某些原因,当我将两者与括号结合使用时,它不起作用。

I believe I am using MS-Access 2013, if that helps. 我相信我正在使用MS-Access 2013,如果这有帮助的话。 By the way, I'm an Access and an SQL newbie. 顺便说一下,我是一个Access和一个SQL新手。

The correct logic is: 正确的逻辑是:

SELECT A.* INTO C
FROM A LEFT JOIN
     B
     ON A.Id = B.Id
WHERE B.Id IS NULL;

You do not need two joins. 您不需要两个连接。 My guess is that the problem with your query is that B appears twice in the FROM clause, without a table alias. 我的猜测是你的查询问题是BFROM子句中出现两次,没有表别名。 MS Access doesn't know what the second B refers to. MS Access不知道第二个B指的是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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