Skip to content

SQL NOT Operator

Syntax

The NOT operator in SQL is used to reverse the result of a condition. It returns TRUE if the condition is FALSE, and FALSE if the condition is TRUE.

-- Negate a condition
SELECT column1, column2
FROM table_name
WHERE NOT condition;

Example

-- Exclude a specific department
SELECT name, department
FROM employees
WHERE NOT department = 'HR';
/* Output:
| name | department |
|------------|------------|
| John Doe | Sales |
| Jane Smith | Marketing |
*/