⚡ 180+ new openings posted today

SQL Not IN Operators

The NOT IN operator is used in WHERE condition with SELECT, UPDATE, and DELETE statement.

The NOT IN operator returns values that do not matches values in a list or subquery.

Syntax

SELECT column_name
FROM table_name
WHERE column_name NOT IN (value1, value2, value3);

Example

SELECT *
FROM Students
WHERE Course NOT IN ('BCA', 'MCA');

This returns students whose course is not BCA and not MCA.

Suppose we have a Students table:

RollNoNameCourse
101AaravBCA
102MeeraBBA
103KabirBTech
104RiyaMCA
105ArjunBBA

Query

SELECT *
FROM Students
WHERE Course NOT IN ('BCA', 'MCA');

Result

RollNoNameCourse
102MeeraBBA
103KabirBTech
105ArjunBBA

Here, SQL excludes students whose course is BCA or MCA.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top