Tsallaka zuwa abun ciki
Justice Tech School

The IN Operator

IN is a short way to write several OR conditions. NOT IN excludes the listed values. Be careful: NOT IN returns nothing if the list contains a NULL.

Example
SELECT name, country
FROM students
WHERE country IN ('Ghana', 'Kenya');

Result

name    | country
Kofi    | Ghana
Wanjiru | Kenya
Esi     | Ghana
Example
SELECT name
FROM students
WHERE id NOT IN (1, 2, 3)
ORDER BY id;

Result

name
Wanjiru
Tunde
Zainab
Sipho
Esi

Exercise

Match any of the listed countries.

SELECT * FROM students WHERE country  ('Ghana', 'Kenya');

Quiz Test

IN is a short form of several...

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.