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');
Result on the SQL Café sample data (5 rows)
namecity
AvaAustin
CaraDenver
DevAustin
GusDenver
HanaAustin

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);
Result on the SQL Café sample data (7 rows)
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);
Result on the SQL Café sample data (1 row)
name
Fay

Common mistakes

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.

Related SQL tutorials