我想运行一个简单的查询来抛出 Table1
的所有行,其中主列值不存在于另一个表 (Table2
) 的列中.
I wanted to run a simple query to throw up all the rows of Table1
where a principal column value is not present in a column in another table (Table2
).
我尝试使用:
SELECT * FROM Table1 WHERE Table1.principal NOT IN Table2.principal
这反而会引发语法错误.谷歌搜索把我带到论坛,那里有人说 MySQL 不支持 NOT IN
并且需要使用一些非常复杂的东西.这是真的?还是我犯了一个可怕的错误?
This is instead throwing a syntax error. Google search led me to forums where people were saying that MySQL does not support NOT IN
and something extremely complex needs to be used. Is this true? Or am I making a horrendous mistake?
要使用 IN,必须有一个集合,请改用以下语法:
To use IN, you must have a set, use this syntax instead:
SELECT * FROM Table1 WHERE Table1.principal NOT IN (SELECT principal FROM table2)
这篇关于MySQL“不在"询问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!