Skip
Arish's avatar

37. The NOT IN Operator


NOT IN

Excludes values in a list.

Syntax

sql
1SELECT * FROM students
2WHERE course NOT IN ('Python', 'Ruby');

Example

Find students NOT in Python or Ruby:

sql
1SELECT * FROM students
2WHERE course NOT IN ('Python', 'Ruby');

With Numbers

sql
1-- Not aged 12 or 14
2SELECT * FROM students
3WHERE age NOT IN (12, 14);