Filtering 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.

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';
Question. Show the name and form of every student who is not in form 11A.
Answer. "Not equal to" is <>. The form is text, so '11A' goes in single quotes:
SELECT name, form FROM student WHERE form <> '11A';
name | form
Jamal | 11B
Tom | 11B
Check each row against the test: Mei, Sara and Lin are in 11A, so form <> '11A' is false for them and they are left out.
- Text without quotes.
WHERE form = 11Afails withunrecognized token: "11A". WriteWHERE form = '11A'. =>is not an operator. Write>=(and<=): the=always comes second.WHEREgoes afterFROM.SELECT name WHERE score > 80 FROM studentis a syntax error.
WHERE lọc các hàng
WHERE keeps only the rows whose condition is true.
Độ khó 2/5 · 140 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Show the name và score of every student who scored 80 or more.
Nhấn Chạy để xem kết quả ở đây.
Độ khó 2/5 · 140 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Show the name of every student in form 11B. (Text goes in single quotes.)
Nhấn Chạy để xem kết quả ở đây.
Độ khó 2/5 · 140 xu + phần thưởng nhỏ khi hoàn thành lần đầu tiên hôm nay
Show the name và score of every student who scored less than 75.
Nhấn Chạy để xem kết quả ở đây.