All SQL topics
SQL TOPIC

SQL LIKE, IN and BETWEEN: match patterns, lists and ranges

LIKE matches text patterns, IN checks a list of values, BETWEEN checks an inclusive range.

In LIKE, % means any number of characters and _ means exactly one: email LIKE '%@example.com' finds one domain.

IN ('Greece', 'Italy') is shorter than several ORs. BETWEEN 100 AND 300 includes both ends, which matters for dates: BETWEEN '2026-01-01' AND '2026-03-31' covers the first quarter.

Worked example

Which products cost between €40 and €100?

SELECT name, price
FROM products
WHERE price BETWEEN 40 AND 100
ORDER BY price;
Result on the sample data
nameprice
USB-C hub45
Bluetooth speaker79
Mechanical keyboard89

Common mistakes

  • Forgetting the % in a LIKE pattern, which turns it into an exact match.
  • Forgetting that BETWEEN includes both ends.