Skip to main content

IN Operator

IN is a concise alternative to multiple OR comparisons on the same column.

Core Concepts

flowchart LR
A[Column value] --> B{Is value in list?}
B -->|Yes| C[Include row]
B -->|No| D[Exclude row]
StyleExample
Multiple ORsstatus='new' OR status='paid'
IN liststatus IN ('new','paid')

Code Examples

-- Reuse orders_cmp table from earlier concept.
SELECT order_id, total, status
FROM orders_cmp
WHERE status IN ('new', 'paid')
ORDER BY order_id;
order_idtotalstatus
119.99new
2120.00paid
375.50new
-- Equivalent logic with OR (longer form).
SELECT order_id, total, status
FROM orders_cmp
WHERE status = 'new' OR status = 'paid'
ORDER BY order_id;
order_idtotalstatus
119.99new
2120.00paid
375.50new

SQLite-Specific Nuances

SQLite Nuance

IN supports literal lists and subqueries in SQLite.

Common Pitfalls / Best Practices

Pitfall

Using long repeated OR chains when IN would be clearer and less error-prone.

Best Practice

Use IN whenever you compare one column against multiple specific values.

Quick Challenge

Return rows from orders_cmp where status is either new or pending.

View Solution
SELECT order_id, total, status
FROM orders_cmp
WHERE status IN ('new', 'pending');
order_idtotalstatus
119.99new
375.50new