SQLite NOT Keyword
The SQLite NOT keyword is used with a SQLite WHERE clause and displays a record where the specified condition is not true.
Syntax
The syntax for using NOT keyword in SQLite is given below:
SELECT column1, column2, column3, ... FROM table_name WHERE NOT condition;
Example:
Consider a database table called Employee with the following records:
EmpID | Name | City | Age | Salary |
---|---|---|---|---|
1 | John | London | 25 | 3000 |
2 | Marry | New York | 24 | 2750 |
3 | Jo | Paris | 27 | 2800 |
4 | Kim | Amsterdam | 30 | 3100 |
5 | Ramesh | New Delhi | 28 | 3000 |
6 | Huang | Beijing | 28 | 2800 |
-
To select all records of the Employee table where City is NOT "New Delhi", the query is given below.
SELECT * FROM Employee WHERE NOT City = 'New Delhi';
This result of the query is shown below:
EmpID Name City Age Salary 1 John London 25 3000 2 Marry New York 24 2750 3 Jo Paris 27 2800 4 Kim Amsterdam 30 3100 6 Huang Beijing 28 2800
❮ SQLite Keywords