NOT IN Operators with Number
Example: Find the Name of the Employees who have not a Age equal to 23, 22, or 21.
Query
SELECT Name
FROM Emp
WHERE age NOT IN (23, 22, 21);
Output
SQL NOT IN Operator
In SQL Server, the NOT IN operator replaces a set of arguments with the <> or != operator that is combined with the AND operator. This operator can be used to make code more readable and easier to understand for SQL statements like SELECT, UPDATE, and DELETE. In most cases, it won’t affect performance.
Syntax:
SELECT column_name(s)
FROM table_name
WHERE column_name NOT IN (list_of_values);
Let’s create a database to understand NOT IN Operator in SQL.