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;
Result on the SQL Café sample data (3 rows)
nameprice
Espresso3
Peppermint Tea3.25
Lemonade3.5

Filter by text

Put text values in single quotes.

SELECT name, calories
FROM drinks
WHERE category = 'tea';
Result on the SQL Café sample data (3 rows)
namecalories
Matcha Latte240
Chai Latte230
Peppermint Tea0

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';
Result on the SQL Café sample data (3 rows)
namejoined
Fay2024-05-19
Gus2024-06-01
Hana2024-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.

Does WHERE work with UPDATE and DELETE?

Yes, and it’s essential there: it decides which rows change. See UPDATE and DELETE.

Related SQL tutorials