NOT IN Operator with Strings
NOT IN operator is used to find out the data that is not present in the table. We can also use NOT IN to exclude the rows in your list. We should note that any kind of duplicate entry will be retained.
Example: Find the Name of all the Employees who are not belong to not Australia or Austria
Query
SELECT name FROM Emp WHERE country NOT IN ('Australia', 'Austria');
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.