SQL IN Operator
IN checks whether a value is in a list. It’s a shorter, clearer way to write several OR conditions on the same column.
Updated December 1, 2026
Syntax
WHERE column IN (value1, value2, ...)
WHERE column NOT IN (SELECT column FROM other_table)
Match a list of values
Customers in Austin or Denver.
SELECT name, city
FROM customers
WHERE city IN ('Austin', 'Denver');
| name | city |
|---|---|
| Ava | Austin |
| Cara | Denver |
| Dev | Austin |
| Gus | Denver |
| Hana | Austin |
IN with a subquery
The list can come from another query. These are the customers who have ordered at least once.
SELECT name
FROM customers
WHERE id IN (SELECT customer_id FROM orders);
| name |
|---|
| Ava |
| Ben |
| Cara |
| Dev |
| Eli |
| Gus |
| Hana |
NOT IN
NOT IN keeps rows that don’t match any value. Fay is the only customer who hasn’t ordered.
SELECT name
FROM customers
WHERE id NOT IN (SELECT customer_id FROM orders);
| name |
|---|
| Fay |
Common mistakes
NOT INwith a subquery that returns a NULL matches nothing at all. Filter NULLs out of the subquery, or useNOT EXISTSor a LEFT JOIN.city IN ('Austin')doesn’t match rows where city is NULL, and neither doesNOT IN.- Forgetting quotes around text values in the list.
Practice IN Operator interactively
Write real queries in your browser and get instant feedback in the lesson “IN, BETWEEN, LIKE” (Unit 2). New learners can start free from the first lesson.
Frequently asked questions
IN vs EXISTS: which is faster?
Modern databases usually plan them the same way. NOT EXISTS is safer than NOT IN when NULLs are possible.
How many values can IN have?
Hundreds is fine in practice. For thousands, load them into a table and join instead.