Filtering with WHERE
Handout
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';
Show the name and score of every student who scored 80 or more.
Click Run to see the output here.
Show the name of every student in form 11B. (Text goes in single quotes.)
Click Run to see the output here.