0

I am trying to achieve and NOT operation and NAND operation in between Queries.

Scenario 1:

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

Works well; Shows all other countries other than the two country which I am mentioning.

Scenario 2:

When I try with some select inside the where condition it shows errors.

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

It shows an error..

Kindly refer the Link: With my previous question and the working of NOT and NAND operation.

MySQL NAND/NOR operations in Queries

Community
  • 1
  • 1
DonOfDen
  • 3,968
  • 11
  • 62
  • 112

1 Answers1

1

AND should be replaced by UNION and the primary key of table (let it assume id) should be checked with NOT IN clause.

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'
        );
sarwar026
  • 3,821
  • 3
  • 26
  • 37