IN

An operator that is true when a value equals any value in a list or in the rows a subquery returns.

In more detail

WHERE status IN ('paid', 'pending') is shorter and clearer than a chain of ORs. NOT IN has a trap: if the list contains a NULL, the comparison can never be true, so the query returns no rows at all. Use NOT EXISTS or an anti join instead.

Example

WHERE id IN (SELECT customer_id FROM orders WHERE status = 'pending')

Related terms

Taught in

References