Filtering with WHERE
This page needs a recent browser (with SharedArrayBuffer support). Please update Chrome, Edge, Firefox or Safari to the latest version.
Filtering rows with WHERE
So far every query returned all the rows. Add a WHERE clause to keep only the rows that match a condition:
SELECT name, score FROM student WHERE score >= 80;
Only rows where the condition is true are returned.
Comparison operators
You can compare with:
=equal to<>not equal to<less than,>greater than<=at most,>=at least
Numbers are written plainly (80). Text must go in single quotes ('11B'):
SELECT name FROM student WHERE form = '11B';
Common mistakes
- Text values go in single quotes:
WHERE name = 'Ann'. WHEREcomes afterFROM.
Explore
WHERE filters rows
WHERE keeps only the rows whose condition is true.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Show the name and score of every student who scored 80 or more.
Click Run to see the output here.
Difficulty 2/5 · 140 coins + a small bonus on first completion today
Show the name of every student in form 11B. (Text goes in single quotes.)
Click Run to see the output here.