SQL NOT Operator

SQL NOT Operator
In SQL NOT Operator is used to negate a condition.
It returns rows where the condition is FALSE.
You typically use NOT within the WHERE clause.
1. Basic Syntax
2. Example: Basic NOT Condition
Return all employees not in the IT department:
Equivalent to:
3. NOT with IN
This returns all customers outside these countries.
4. NOT with LIKE
Returns products whose names do not start with “A”.
5. NOT with BETWEEN
Returns amounts less than 100 or greater than 500.
6. NOT with NULL Checks
Important: Use IS NOT NULL, not NOT NULL.
7. NOT with Boolean Columns
Equivalent to:
8. NOT with Complex Expressions
This returns rows where:
status ≠ ‘active’
OR priority ≠ ‘high’
(or both)
Using parentheses is recommended when negating combined conditions.
9. Real-World Example
Get all active users who have not verified their email:
