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;
זה מחזיר תלמידי 11A שגם קיבלו ציון מעל 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. · שלבבו תנאים באמצעות AND/OR/NOT — ראו את טבלת האמת.
Show the name of every student who is in form 11A and scored more than 88. · הציגו את הname של כל תלמיד שהוא בקבוצה 11A וגם קיבל ציון מעל 88.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Show the name of every student who is in form 11B or scored 95 or more. · הציגו את הname של כל תלמיד שהוא בקבוצה 11B או קיבל ציון 95 או יותר.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.