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 ID | Customer Name | City | PostalCode | Country |
|---|---|---|---|---|
| 1 | John Wick | New York | 1248 | USA |
| 2 | Around the Horn | London | WA1 1DP | UK |
| 3 | Rohan | New Delhi | 100084 | India |
NOT Example
The following SQL statement selects all fields from “Customers” where country is not “UK”
SELECT * FROM Customers WHERE NOT Country=’UK’;
| Customer ID | Customer Name | City | PostalCode | Country |
|---|---|---|---|---|
| 1 | John Wick | New York | 1248 | USA |
| 3 | Rohan | New Delhi | 100084 | India |
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 ID | Customer Name | City | PostalCode | Country |
|---|---|---|---|---|
| 3 | Rohan | New Delhi | 100084 | India |
Recommended Posts:
- SQL | BETWEEN & IN Operator
- SQL | MINUS Operator
- SQL | Concatenation Operator
- SQL | Alternative Quote Operator
- SQL | SELECT Query
- SQL | Distinct Clause
- SQL | WHERE Clause
- SQL | AND and OR operators
- SQL | INSERT INTO Statement
- SQL | DELETE Statement
- SQL | UPDATE Statement
- SQL | SELECT TOP Clause
- SQL | ORDER BY
- SQL | Aliases
- SQL | Wildcard operators
- SQL | Join (Inner, Left, Right and Full Joins)
- SQL | Union Clause
- SQL | Join (Cartesian Join & Self Join)
- SQL | CREATE
- SQL | DROP, TRUNCATE


