SQL Not在查询中使用Access而不是MySQL

时间:2014-02-03 15:55:25

标签: mysql sql

我一直在努力让这个SQL查询生效。它适用于Access,但不适用MySQL给我错误

#1064 - 您的SQL语法出错;

任何人都可以看到我的错误吗? Not In是不允许的?

我的第一个查询是

SELECT departments.personName FROM departments WHERE departments.departmentName='HR';

然后将其嵌入到下一个查询

SELECT DISTINCT allstaff.personName FROM allstaff
WHERE allstaff.personName Not In 
(SELECT departments.personName FROM departments WHERE departments.departmentName='HR';);

2 个答案:

答案 0 :(得分:1)

在您的查询结束时,将;);替换为);

答案 1 :(得分:1)

请删除分号(;)

试试这个

SELECT DISTINCT allstaff.personName FROM allstaff
WHERE allstaff.personName Not In 
(SELECT departments.personName FROM departments WHERE departments.departmentName='HR');