This SQLite post explains how to use the SQLite NOT condition with syntax and examples.
The SQLite NOT Condition (also called the NOT Operator) is used to negate a condition in a SELECT, INSERT, UPDATE, or DELETE statement.
The syntax for the NOT Condition in SQLite is:
The condition to negate.
The SQLite NOT condition can be combined with the IN Condition.
For example:
This SQLite NOT example would return all rows from the employees table where the department is not 'Accounting', 'Finance', or 'HR'. Sometimes, it is more efficient to list the values that you do not want, as opposed to the values that you do want.
The SQLite NOT condition can also be combined with the IS NULL Condition.
For example,
This SQLite NOT example would return all records from the employees table where the department does not contain a NULL value.
The SQLite NOT condition can also be combined with the LIKE Condition.
For example:
By placing the SQLite NOT Operator in front of the LIKE condition, you are able to retrieve all employees whose last_name does not start with 'A'.
The SQLite NOT condition can also be combined with the BETWEEN Condition. Here is an example of how you would combine the NOT Operator with the BETWEEN Condition.
For example:
This SQLite NOT example would return all rows from the employees table where the employee_id is NOT between 5 and 10, inclusive. It would be equivalent to the following SELECT statement:
The SQLite NOT condition can also be combined with the EXISTS Condition.
For example,
This SQLite NOT example would return all records from the employees table where there are no records in the positions table for the given position_id.