我正在尝试在查询之间实现AND NOT操作和NAND操作。
场景 1:
SELECT
country_name,country_code
from country
where not (country_name='Land islands' and country_code='AX');
效果很好;显示除我提到的两个国家之外的所有其他国家。
场景 2:
当我尝试在 where 条件内进行一些选择时,它显示错误。
SELECT * from
country
where not
(SELECT * from country
where country_name='Land islands'
and
SELECT * from country
where country_code='AX');
显示错误..
Kindly refer the Link:结合我之前的问题以及 NOT 和 NAND 操作的工作原理。
最佳答案
AND
应替换为 UNION
并且表的主键
(假设id
)应使用 NOT IN
子句进行检查。
SELECT * from country
WHERE id NOT IN
(SELECT id from country
where country_name='Land islands'
UNION
SELECT id from country
where country_code='AX'
);
关于Mysql 具有 NAND 操作和 NOT 操作的多个查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16938865/