[英]error of sql query in MS Access database
I need to do a sql query in MS Access. 我需要在MS Access中执行sql查询。
But I got error in MS Access: 但是我在MS Access中遇到错误:
SELECT *
FROM
(
SELECT *
FROM table1
where not exists
(
SELECT *
FROM table2
where table2.id = table1.id
) as t
) as t1, table3
where table3.id = t1.id
Syntax error: (missing operator) in query expression 'not exists ( ... ) as t' 语法错误:查询表达式“不存在(...)作为t”中的(缺少运算符)
Any help would be appreciated. 任何帮助,将不胜感激。
The not exists subselect does not require an alias. 不存在子选择不需要别名。 Note that I've removed the
as t
请注意,我已经删除了
as t
SELECT *
FROM
(
SELECT *
FROM table1
where not exists
(
SELECT *
FROM table2
where table2.id = table1.id
)
) as t1, table3
where table3.id = t1.id
You might also consider using an inner join
and a left join
to get rid of your not exists
: 您还可以考虑使用
inner join
和left join
来摆脱not exists
:
This should be exactly equivalent of the above: 这应该与上述内容完全相同:
SELECT t1.*, t3.*
FROM
table1 t1
inner join table3 t3 on t1.id = t3.id
left join table2 t2 on t1.id = t2.id
where
t2.id is null
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.