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 |
|---|
Alternatively you can use <> ( Not Operator) to get the desired result :-
SELECT * FROM Customer WHERE Country <>'USA';
Output :-
Last Updated :
24 Mar, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...