NOT Operator:
The SQL NOT operator is used to reverse a condition in a SQL query. It is used with SELECT, DELETE, UPDATE, or INSERT statement. It can be used with other operators like BETWEEN, IN , EXISTS but it will reverse the condition.
Syntax:
SELECT *
FROM tablename
WHERE columnname NOT condition;
Example 1:
SELECT *
FROM Employee
WHERE Empname NOT IN ( 'Sam', 'John ', 'Mitchell' );
The above query will find those employee records whose name are not given within IN operator.
Example 2:
SELECT *
FROM Employee
WHERE city IS NOT NULL;
The above query will find those employee records whose city column are not having NULL value.
Example 3:
SELECT *
FROM Employee
WHERE Salary IS NOT BETWEEN 5000 AND 8000;
The above query will find those employee records whose salaries are not between 5000 and 8000.
0 Comment(s)