Blog · Guide

SQL IN and BETWEEN: Cleaner Filters for Lists and Ranges

IN replaces a pile of ORs. BETWEEN handles inclusive ranges. When to use each.

all rows WHERE kept rows
WHERE keeps only the rows that match your condition.

IN = membership in a list

WHERE city IN ('Austin', 'Chicago', 'Milan')

Same idea as multiple ORs, easier to read. Great for “these statuses” or “these countries.”

BETWEEN = inclusive range

WHERE price BETWEEN 3 AND 8

Includes both ends (3 and 8). Works for numbers and dates. For practice on ranges, try the BETWEEN exercise next.

Try it yourself

The fastest way to lock this in is a short drill on the same Northstar Market tables.

Practice WHERE IN

Related guides