Run WHERE-clause queries against the mock students table. Try the preset examples or write your own filter.
Table: students — id | name | grade | score | city
1:Alice/10/92/Tulsa 2:Bob/11/78/OKC 3:Carlos/10/85/Tulsa
4:Diana/12/95/Norman 5:Ethan/11/71/OKC 6:Fiona/12/88/Tulsa
The WHERE Clause
WHERE filters which rows are included in the result. Only rows where the condition is TRUE are returned. WHERE comes after FROM but before ORDER BY and LIMIT.
Comparison operators: = equal, != or <> not equal, >, <, >=, <=
AND, OR, NOT
AND — both conditions must be true
OR — at least one condition must be true
NOT — inverts the condition. NOT (score > 80) is the same as score <= 80
Use parentheses to group conditions: WHERE grade = 10 AND (score > 80 OR city = 'Tulsa')
LIKE, BETWEEN, IN, IS NULL
WHERE name LIKE 'A%' — names starting with A. % matches any string, _ matches one character.
WHERE score BETWEEN 80 AND 90 — inclusive range (80 and 90 included).
WHERE city IN ('Tulsa', 'OKC') — matches any value in the list.
WHERE email IS NULL — checks for missing values. Never use = NULL.
Quick Check
1. What does WHERE score >= 90 return?
Rows where score equals 90 exactly
Rows where score is 90 or higher
Rows where score is above 90 only
All rows except score 90
2. What does the % wildcard mean in a LIKE pattern?
Exactly one character
Zero or more characters of any type
Only a digit
A literal percent sign only
3. How do you check if a column is empty/missing in SQL?