[英]error of sql query in MS Access database
我需要在MS Access中执行sql查询。
但是我在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
语法错误:查询表达式“不存在(...)作为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
您还可以考虑使用inner join
和left join
来摆脱not exists
:
这应该与上述内容完全相同:
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.