0

我试图在查询之间实现和 NOT 操作和 NAND 操作。

场景一:

 SELECT 
    country_name,country_code 
       from country 
       where not (country_name='Land islands' and country_code='AX');

效果很好; 显示除我提到的两个国家以外的所有其他国家。

场景二:

当我尝试在 where 条件下使用一些选择时,它会显示错误。

 SELECT * from
   country 
     where not 
       (SELECT * from country 
              where country_name='Land islands' 
        and 
        SELECT * from country
               where country_code='AX');

它显示一个错误..

请参考链接:我之前的问题以及 NOT 和 NAND 操作的工作。

查询中的 MySQL NAND/NOR 操作

4

1 回答 1

1

AND应该被替换,UNION并且应该用子句检查primary key表(让它假设)。idNOT 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'
        );
于 2013-06-05T11:37:17.480 回答