SQL WHERE, explained
WHERE keeps only the rows that match a condition. It comes after FROM, and the database checks the condition once for every row.
Combine conditions with AND (both must be true) or OR (either can be true). Text goes in single quotes and numbers do not.
Examples
1. Filter on text and numbers
SELECT id, total
FROM orders
WHERE status = 'delivered' AND total > 100;Keeps delivered orders worth more than 100.
2. Find missing values
SELECT name
FROM customers
WHERE email IS NULL;NULL means "unknown", so = NULL never matches. Use IS NULL instead.
Practice WHERE
5 questions, easiest first. Your progress is saved on this device.
- โFilter by texteasy
- ๐Filter by numbereasy
- ๐Two conditionsmedium
- ๐A date rangemedium
- ๐Missing valuesmedium