SQL Keyword - NOT

NOT Keyword

The NOT keyword is used to check if a condition is not true.

The NOT keyword is used with the where clause and returns only those rows where the condition is not true.

Syntax

SELECT * FROM WHERE NOT <CONDITION>

Example 1

SELECT * FROM Employee WHERE NOT Emp_Id = 1

It will return all rows except those with an Emp_Id of 1. 

Example 2

SELECT * FROM Employee WHERE Emp_Id NOT IN (1,5,7)

It will return all rows except those with an Emp_Id of 1, 5, or 7. 

Example 3

SELECT * FROM Employee WHERE Emp_Name NOT LIKE 'B%'

It will return all rows excluding those whose emp_name starts with 'B'.

Summary

This NOT keyword is utilised with the WHERE clause to include those that record where a condition isn't true.

Next Recommended Reading Top Keyword in SQL