In short
Most questions are about some rows, not all of them: orders from Jaipur, payments that failed, students who scored above 80. WHERE is how you keep only the rows that matter.
WHERE keeps only the rows where a condition is true. It runs before grouping and sorting, so it decides which rows the rest of the query ever sees.

Think of it like this
Sieving atta
Pour flour through a chalni and only fine atta falls through, while the husk and small stones stay on top. WHERE is the sieve. Every row is tested against your condition, and only rows that pass fall into the result.
Watch it happen
WHERE city = 'Jaipur'
1/5FROM orders gives every row. WHERE now tests them one by one.
The big ideas
What you need to know
Keeps rows where the condition is TRUE
Each row is checked. FALSE and unknown rows are both thrown away.
Runs early
WHERE runs right after FROM, before SELECT, GROUP BY and ORDER BY. It decides what the rest of the query sees.
Text in single quotes
WHERE city = 'Jaipur'. Numbers need no quotes: WHERE amount > 500.
Text matching can be case-sensitive
In PostgreSQL 'jaipur' does not equal 'Jaipur'. MySQL's default collation ignores case.
See it in code
Walk through the code
1SELECT order_id, city, amount2FROM orders3WHERE city = 'Jaipur';4 5SELECT order_id, status, amount6FROM orders7WHERE status = 'failed'8ORDER BY amount DESC;9 10SELECT name, joined_on11FROM customers12WHERE joined_on >= DATE '2026-01-01';1/3Keep only Jaipur orders.
Three single-condition filters on text, status and dates. Each runs as is in PostgreSQL and MySQL.
Save yourself the pain
Common mistakes
Oops
WHERE city = "Jaipur" with double quotes in PostgreSQL.
Do this instead
Double quotes mean a column name there. Text values always use single quotes.
Oops
Putting WHERE after ORDER BY.
Do this instead
Clause order is fixed: SELECT, FROM, WHERE, GROUP BY, HAVING, ORDER BY, LIMIT.
Your mission
Sieve your data
Quick check
Which clause runs first when the database executes a query?
Go deeper
- 1Filter a table by a number, a text value and a date.
- 2Remember that text and date values need single quotes while numbers do not.
- 3Count rows before and after adding a WHERE to see how much it filters.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.