AND, OR, NOT
Combining conditions
A WHERE clause can test more than one thing at once. Join conditions with:
AND— both must be trueOR— at least one must be trueNOT— flips a condition
This returns 11A students who also scored above 88.
条件の組み合わせ
WHERE クロースは一度に複数のことをテストできます。条件を以下のように接続します:
AND— 両方が真である必要がありますOR— 少なくとも一方が真である必要がありますNOT— 条件を反転させる
SELECT name FROM student WHERE form = '11A' AND score > 88;
此操作将返回 11名同时得分高于 88的学生。
Mixing AND and OR
When you mix AND and OR, use brackets to make the meaning clear, just like in maths:
AND is checked before OR, so brackets remove any doubt about what you mean.
AND と OR を混ぜる
AND と OR を混ぜる際は、数学と同じように意味を明確にするために括弧を使用します:
SELECT name FROM student
WHERE form = '11B' OR score >= 95;
AND は OR より先にチェックされるため、括弧を使うことで意図する結果が曖昧にならずに済みます。
Common mistakes
- Use brackets when you mix
ANDandORto make the order clear. NOTreverses a condition.
よくあるミス
ANDとORを混ぜる際は、順序を明確にするために括弧を使用してください。NOTは条件を反転させます。
AND, OR, NOT
Combine conditions with AND/OR/NOT — see the truth table.
Show the name of every student who is in form 11A and scored more than 88.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。
Show the name of every student who is in form 11B or scored 95 or more.
Click Run to see the output here. · 実行ボタンをクリックして出力を確認してください。