Javatpoint Logo
Javatpoint Logo

SQL Server NOT Condition (Operator)

The SQL Server NOT condition or NOT operator is used to negate a condition in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax:

Parameter explanation

condition: It specifies the condition that you want to negate.


NOT Operator with IN condition

We have a table "Employees", having the following data:

SQL Not condition 1

Example

Retrieve all employees from the table where the following "NOT" condition is satisfied:

Output:

SQL Not condition 2

NOT Operator with IS NULL condition

Retrieve all employees from the table "Employees" which follows the IS NOT NULL condition:

Output:

SQL Not condition 3

NOT Operator with LIKE condition

Retrieve all employees from the table "Employees" which follows the NOT LIKE condition. It will display only names which don?t start with "M".

Output:

SQL Not condition 4

NOT Operator with BETWEEN condition

Retrieve all employees from the table "Employees", which follows the following condition. It will not show the employees between the id 8 to 13.

Output:

SQL Not condition 5

Or

Output:

SQL Not condition 6

NOT Operator with EXISTS condition

You can also combine SQL Server NOT condition with the EXISTS condition.

OR condition:

Output:

SQL Not condition 7

AND Condition:

Output:

SQL Not condition 8

This SQL Server NOT example would return all records from the Employees table where there are no records in the Employee2 table for the matching name and salary.


Next TopicBETWEEN Operator




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


B.Tech / MCA