Other related articles:

Recently viewed articles:

SQL NOT Keyword

When we need to extract data for which we don’t have any direct information handy, we use NOT operators. It will extract information for the records which are not same as the condition. Following SQL statement will select records where the deptno is not equal to 10

SELECT * FROM empWHERE NOT deptno = 10;

This query would give same result as the one below:

SELECT * FROM emp WHERE deptno <> 10;

This query has only one difference that is the use of the “not equal to” (<>) operator  in place of the NOT operator.

You can also use the NOT operator for multiple conditions with the use of  brackets:

SELECT ename FROM emp WHERE NOT (deptno = 10 OR deptno = 20);

This query will return all the records where the conditions inside the brackets are false.

We can also use the NOT operator in combination with other operators such as AND, OR, BETWEEN, ANY, or LIKE.