HOME C C++ PYTHON JAVA HTML CSS JAVASCRIPT BOOTSTRAP JQUERY REACT PHP SQL AJAX JSON DATA SCIENCE AI

SQL NOT Operator

The NOT operator is used in combination with other operators to give the opposite or negative result.

In the below statement we want to return all employee that are NOT from India:

Example

Select only the employee that are NOT from India:
SELECT * FROM employee WHERE NOT Country = 'India' ;
You can click on above box to edit the code and run again.

Output

not operator_country

Syntax

SELECT   column1, column2, ... 
FROM  table_name
WHERE NOT condition;

Demo Employee table


This employee table is used for examples:

demo employee table

NOT LIKE


Example

Select employee that does not start with the letter 'R':
SELECT * FROM employee WHERE Employee_name NOT LIKE 'R%' ;
You can click on above box to edit the code and run again.

Output

 not with like

NOT BETWEEN


Example

Select employee with a Employee id not between 7 and 12:
SELECT * FROM employee WHERE Employee_id NOT BETWEEN 7 AND 12 ;
You can click on above box to edit the code and run again.

Output

 not with between

NOT Greater Than


Example

Select employee with a Employee id not greater than 8:
SELECT * FROM employee WHERE NOT Employee_id > 8 ;
You can click on above box to edit the code and run again.

Output

 not greater than
Note: There is a not-greater-then operator: !> that would give you the same result.

NOT Less Than


Example

Select employee with a Employee id not less than 8:

SELECT * FROM employee
WHERE NOT Employee_id < 8 ;
You can click on above box to edit the code and run again.

Output

 not less than
Note: There is a not-less-then operator: !< that would give you the same result.

NOT IN


Example

Select employee that are not from India or Spain :
SELECT * FROM employee WHERE Country NOT IN ( 'India' , 'Spain' );
You can click on above box to edit the code and run again.

Output

 not with in