N012 Tier 1 · Foundations

BETWEEN, IN, and LIKE in SQL

BETWEEN, IN, and LIKE are shorthand filter operators that expand on the basic comparison operators available in WHERE. Each tests a column value against a range, a set, or a pattern.

BETWEEN, IN, and LIKE are three WHERE operators that make common filter patterns cleaner to write.

They don't add new capabilities. You could express the same logic with the comparison operators you already know. What they add is readability. A range check with two bounds. A membership test against a list. A pattern match on a string. Each shows up constantly in analyst work, and writing them with the shorthand operators instead of long chains of OR keeps queries much easier to read.

You're filtering the product catalog for a specific price range. Your manager wants items between $50 and $200. That's BETWEEN:

SELECT name, price
FROM products
WHERE price BETWEEN 50 AND 200

Both ends of the range are included. A price of exactly $50 qualifies. A price of exactly $200 qualifies. Anything in between qualifies. BETWEEN is shorthand for >= 50 AND <= 200 — both forms produce identical results.

IN tests whether a value matches any member of a list. Instead of chaining multiple equality conditions with OR, you write:

Easy to extend — add another status to the list without restructuring anything. NOT IN inverts it: keep rows where the value doesn't match anything in the list.

LIKE matches a string against a pattern. Two wildcards handle most pattern needs: % matches any sequence of characters (including none), and _ matches exactly one character:

SELECT name, price
FROM products
WHERE name LIKE 'Crest%'

Any product whose name starts with "Crest" passes. The _ wildcard is more precise: 'Apex Titan 1_' matches "Apex Titan 15" but not "Apex Titan 15 Pro" because _ requires exactly one character at that position.

The one thing that trips people up: LIKE is case-sensitive.

WHERE name LIKE 'crest%' will not match a product called "Crest Pro 14" — lowercase c doesn't match uppercase C. For case-insensitive matching, use ILIKE:

SELECT name, title
FROM employees
WHERE title ILIKE '%manager%'

ILIKE is PostgreSQL-specific. It matches regardless of case.

Check your understanding

You write WHERE name LIKE 'apex%'. The table has a product called 'Apex Titan 15'. Does this row match?

Practice

9 BETWEEN, IN, and LIKE practice problems

These problems are part of the BETWEEN, IN, and LIKE lesson in SQLMaxx, with instant grading and a worked solution on each.

How you actually get good at SQL

Reading explains SQL. Writing it, over and over with instant feedback, is what makes you fluent.

That's the whole SQLMaxx loop: 600+ real problems, instant AI feedback, mastery you can actually see, and spaced review that won't let you forget.

A stack of SQL practice problem cards, the top card showing an employees table.
615 problems · 66 concepts

Real problems. Not toy examples.

615 hand-built problems spanning all 66 concepts, from basic SELECTs to window functions, built on real schemas and real business questions, the kind you'll actually get asked on the job. Enough reps to make SQL automatic.

A retro computer showing a SQL query marked correct with a green checkmark.
Instant AI feedback

Write a query. Know if it's right in one second.

No copying an answer and hoping it clicked. The AI grader checks your real query against real data, catches exactly what's wrong, and explains the fix in plain English, like a senior analyst reading over your shoulder on every problem.

A circular mastery progress dial filling from blue to green, the SQLMaxx diamond at its center.
Mastery tracking

Stop guessing whether you actually know it.

SQLMaxx tracks every concept and shows you what you've mastered and what's still shaky. Your skills fill in one concept at a time, so 'I think I get joins' becomes something you can prove.

A SQL query editor circled by a blue return arrow with a clock, scheduled to come back for review.
Spaced review

Learn it once. Keep it for good.

Most of what you learn this week fades by next week. So when a concept comes due for review, SQLMaxx hands you a fresh problem to solve from a blank editor, not a flashcard to re-read. A research-backed spaced-repetition algorithm (FSRS) times each return for right before you'd forget, so your SQL is still there months later, when the interview or the job actually needs it.

Practice, feedback, mastery, review. That's the loop that turns reading into real skill.

Start free

No account, no credit card. Start solving in under a minute.