Filtering with WHERE
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:
Only rows where the condition is true are returned.
WHEREで行をフィルタリングする
これまで、すべての照会がすべての行を返していました。条件に一致する行のみを残すために WHERE クロースを追加します:
SELECT name, score FROM student WHERE score >= 80;
条件が真である行のみが返されます。
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'):
比較演算子
以下で比較できます:
=等しい<>等しくない<より小さい,>より大きい<=最大でも (以下),>=最小でも (以上)
数字はそのまま書きます (80)。テキストは片隅かっかで囲みます ('11B'):
SELECT name FROM student WHERE form = '11B';
Common mistakes
- Text values go in single quotes:
WHERE name = 'Ann'. WHEREcomes afterFROM.
よくあるミス
- テキスト値は単一引用符で囲む:
WHERE name = 'Ann'。 WHEREはFROMの後に来ます。
WHERE filters rows
WHERE keeps only the rows whose condition is true.
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. · 実行ボタンをクリックして出力を確認してください。