SQL WHERE Clause
WHERE keeps only the rows that match a condition. It goes after FROM and before ORDER BY, and the database checks the condition against every row.
Updated December 1, 2026
Syntax
SELECT columns
FROM table_name
WHERE condition;
Filter by a number
Comparison operators are =, <> (or !=), <, <=, > and >=.
SELECT name, price
FROM drinks
WHERE price < 4;
| name | price |
|---|---|
| Espresso | 3 |
| Peppermint Tea | 3.25 |
| Lemonade | 3.5 |
Filter by text
Put text values in single quotes.
SELECT name, calories
FROM drinks
WHERE category = 'tea';
| name | calories |
|---|---|
| Matcha Latte | 240 |
| Chai Latte | 230 |
| Peppermint Tea | 0 |
Filter by date
Dates stored as YYYY-MM-DD text compare correctly, so >= means “on or after”.
SELECT name, joined
FROM customers
WHERE joined >= '2024-05-01';
| name | joined |
|---|---|
| Fay | 2024-05-19 |
| Gus | 2024-06-01 |
| Hana | 2024-06-24 |
Common mistakes
Practice WHERE Clause interactively
Write real queries in your browser and get instant feedback in the lesson “Filter with WHERE” (Unit 2). New learners can start free from the first lesson.
Frequently asked questions
Can WHERE use several conditions?
Yes, combine them with AND, OR and NOT, and use parentheses to make the order clear.