Ad space (banner)
🗄️SQL Lessons
Lesson 30 / 50

Matching Multiple Values with IN

This lesson covers matching multiple values at once with the IN operator, so you can avoid stacking up a chain of ORs. It's for anyone searching "SQL IN operator tutorial."

IN (value1, value2, ...) matches any row where a column equals one of several candidates, without repeating OR over and over.

The example uses WHERE class_id IN (1, 3) to get students in either Class 1 or Class 3. Compare it to the equivalent class_id = 1 OR class_id = 3IN expresses the same thing in one line, and the readability advantage only grows as the list of candidates gets longer.

A common early mistake is forgetting quotes when the values are strings — numbers can be listed plainly, but strings each need their own quotes, like IN ('Class A', 'Class B'). IN can also take a subquery's results as its candidate list, which makes it a genuinely versatile operator — useful for filters like "only students whose ID appears in this other list."

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)