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 200Both 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.
You write WHERE name LIKE 'apex%'. The table has a product called 'Apex Titan 15'. Does this row match?
9 BETWEEN, IN, and LIKE practice problems
Write a query to return the name and price of every qualifying product.
Write a query to return the ID and status of each such order.
Write a query to return the name and price of every product whose name begins with `Crest`.
Write a query to return each qualifying product's name, its regular price, and its discounted member price (the regular price scaled by 0.8).
Write a query to return the ID, name, and country of every customer in those three territories.
Write a query to return the name and title of every employee currently in a management role.
Write a query to return the ID, status, and total amount for every order that is neither `delivered` nor `cancelled`.
Write a query to return the name of every product that qualifies.
Write a query to return the name and price of any products that match the user's pattern as submitted.
These problems are part of the BETWEEN, IN, and LIKE lesson in SQLMaxx, with instant grading and a worked solution on each.
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.
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.
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.
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.
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 freeNo account, no credit card. Start solving in under a minute.