Skip to content
Related Articles

Related Articles

Improve Article
SQL | NOT Operator
  • Difficulty Level : Medium
  • Last Updated : 21 Mar, 2018

NOT Syntax
SELECT column1, colomn2, … FROM table_name WHERE NOT condition;
Demo Database
Below is a selection from the “Customers” table in the Northwind sample database:

Customer IDCustomer NameCityPostalCodeCountry
1John WickNew York1248USA
2Around the HornLondonWA1 1DPUK
3RohanNew Delhi100084India

NOT Example
The following SQL statement selects all fields from “Customers” where country is not “UK”
SELECT * FROM Customers WHERE NOT Country=’UK’;

Customer IDCustomer NameCityPostalCodeCountry
1John WickNew York1248USA
3RohanNew Delhi100084India

Combining AND, OR and NOT
You can also combine the AND, OR and NOT operators.
Example:
1.) SELECT * FROM Customers WHERE NOT Country=’USA’ AND NOT Country=’UK’;

Customer IDCustomer NameCityPostalCodeCountry
3RohanNew Delhi100084India
My Personal Notes arrow_drop_up
Recommended Articles
Page :