Español Practice SQL

SQL IN, BETWEEN, LIKE and IS NULL

Four filters that make WHERE shorter and safer: lists, ranges, patterns and missing values.

SQL skills · One table

Practice this nowLearn it step by step

Free. No sign up. Your progress stays in this browser.

What you will learn

IN checks a value against a list, BETWEEN keeps a range, LIKE finds text by a pattern, and IS NULL finds empty values.

The last one matters most: = NULL never works, and it is one of the most common SQL bugs.

The basics

IN: a list of values

WHERE region IN ('East', 'West')

The same as region = 'East' OR region = 'West', only shorter. NOT IN keeps everything except the list.

BETWEEN: a range

WHERE amount BETWEEN 1000 AND 5000
WHERE due_date BETWEEN '2026-03-01' AND '2026-03-31'

Both ends are included. Write the smaller value first.

LIKE: part of a text

WHERE customer LIKE 'S%'
WHERE campaign_name LIKE '%Sale%'

% stands for any text, even none. _ stands for exactly one character. In SQLite and MySQL, LIKE ignores the case of English letters; PostgreSQL has ILIKE for that.

NULL: a missing value

WHERE paid_date IS NULL
WHERE paid_date IS NOT NULL

NULL means the value is unknown or missing. It is not zero and not empty text. Any comparison with NULL using = is never true, so WHERE paid_date = NULL returns no rows. Always use IS NULL.

Worked examples

Example 1

Invoices in the East or West region, between $1,000 and $5,000.

SELECT customer, region, amount
FROM invoices
WHERE region IN ('East', 'West')
  AND amount BETWEEN 1000 AND 5000

BETWEEN includes both ends.

Example 2

Tickets that are still open, which means they have no closed date.

SELECT ticket_id, customer
FROM tickets
WHERE closed_date IS NULL

NULL means the value is missing. Find it with IS NULL.

Reading helps, typing makes it stick. Every task gives you a fresh table, and your query is checked by a real database.

Try a task

Common mistakes

  • Writing WHERE paid_date = NULL, which returns nothing at all.
  • Putting the larger number first in BETWEEN, which also returns nothing.
  • Forgetting the % in LIKE: LIKE 'S' only matches the text S.

Where you will use it at work

  • Finance: invoices with no paid date yet.
  • Marketing: campaigns whose name contains Holiday.
  • HR: employees in two or three chosen locations.

Questions people ask

What does % mean in LIKE?

Any text, including none. 'S%' starts with S, '%Labs' ends with Labs, '%sale%' contains sale.

Is NULL the same as zero or empty text?

No. NULL means unknown or missing. Zero and empty text are real values.

What is NOT IN?

The opposite of IN: everything except the values in the list. Be careful if the list can contain NULL, which makes NOT IN return nothing.

Ready to write it yourself?

Practice IN, BETWEEN, LIKE and NULL

Related guides