How to Use IN in SQL
Use IN when a column should match one of several exact values. This is much cleaner than chaining multiple OR conditions and works especially well for filters, role checks, and grouped reporting.
What you’ll build or solve
You’ll learn how to use IN in SQL with exact-match lists and subqueries. You’ll also know when it reads better than repeated OR logic.
Learn SQL on Mimo
When this approach works best
This approach is the right choice when one column can match several known values.
Common real-world scenarios include:
- Multiple order statuses
- Selected user roles
- Country filters
- Product category sets
- ID list lookups
This is a bad idea when the condition is range-based. In that case, use comparison operators or BETWEEN.
Prerequisites
You only need:
- A SQL table with rows
- Basic
SELECTandWHEREknowledge
Step-by-step instructions
Step 1: Add IN with a list of exact values
Place IN after the target column.
SQL
SELECT *
FROM orders
WHERE status IN ('paid', 'pending', 'refunded');
This returns rows where status matches any listed value.
This is cleaner than repeating:
SQL
WHERE status = 'paid'
OR status = 'pending'
OR status = 'refunded'
IN also works with numeric IDs.
SQL
SELECT *
FROM users
WHERE user_id IN (5, 9, 12);
What to look for:
INchecks multiple exact values- Cleaner than repeated
OR - Works with strings and numbers
- Great for grouped filters
- Use subqueries for dynamic lists
Examples you can copy
Multiple roles
SQL
SELECT *
FROM users
WHERE role IN ('admin', 'editor');
Selected products
SQL
SELECT *
FROM products
WHERE product_id IN (101, 102, 103);
Country filter
SQL
SELECT *
FROM customers
WHERE country IN ('USA', 'UK', 'France');
Common mistakes and how to fix them
Mistake 1: Forgetting parentheses
What the reader might do:
SQL
WHERE status IN 'paid', 'pending'
Why it breaks: IN requires parentheses around the list.
Corrected approach:
SQL
WHERE status IN ('paid', 'pending')
Mistake 2: Mixing data types
What the reader might do:
SQL
WHERE user_id IN ('5', '9')
Why it breaks: string IDs may behave differently on numeric columns.
Corrected approach:
SQL
WHERE user_id IN (5, 9)
Mistake 3: Using IN for ranges
What the reader might do:
SQL
WHERE total IN (100, 200, 300)
Why it breaks: this checks only exact totals.
Corrected approach:
Use range operators.
SQL
WHERE total BETWEEN 100 AND 300
Troubleshooting
If nothing matches, verify the exact values and data types.
If the syntax errors, check the parentheses.
If the list becomes dynamic, switch to a subquery.
If the filter is a numeric range, use BETWEEN or comparison operators.
Quick recap
- Use
INfor multiple exact values - Cleaner than repeated
OR - Always wrap values in parentheses
- Match data types correctly
- Use ranges for numeric spans
Join 35M+ people learning for free on Mimo
4.8 out of 5 across 1M+ reviews
Check us out on Apple AppStore, Google Play Store, and Trustpilot