skip to today's puzzle

WHERE keeps only the rows you want

WHERE filters which rows appear in your results: the database checks your test one row at a time, and only rows that pass are returned. Rows that don't pass are left behind. Without WHERE, you get every row in the table. Picking columns is still SELECT's job — WHERE only decides which rows.

A tiny example

In plain English: Show me the names of the menu items in the breakfast category.

SELECT name, category
FROM menu_items
WHERE category = 'breakfast';

Query result

namecategory
Sconebreakfast
Croissantbreakfast
Muffinbreakfast

Scone, croissant, and muffin are the only menu items in the breakfast category, so they’re the only rows that appear in your results.

Common questions

Where does WHERE go in a SQL query?
After FROM and before GROUP BY, HAVING, ORDER BY and LIMIT. The database applies it early, so only matching rows carry on to the later clauses.
Can WHERE test more than one thing?
Yes. Combine checks with AND and OR, and use parentheses to make the grouping clear, such as WHERE city = 'Austin' AND (price >= 4 OR size = 'large').

Related SQL lessons

Practice WHERE step by step

The Foundations Track has beginner puzzles built around this idea. Tap tiles, see real results. No terminal, no setup.

practice this in the course

Ready for a break?

A fresh, bite-sized SQL puzzle waits every morning. Tap tiles, see real results. No terminal, no setup, no timers.

Try today's free SQL puzzle