Filtering with WHERE · סינון עם 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 מסנן שורות
WHERE keeps only the rows whose condition is true. · WHERE שומר רק את השורות שבהן התנון מתקיים.
Show the name and score of every student who scored 80 or more. · הציגו את הname והscore של כל תלמיד שקיבל ציון 80 או יותר.
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.
Show the name of every student in form 11B. (Text goes in single quotes.) · הציגו את הname של כל תלמיד בקבוצה 11B. (הטקסט נכתב בתוך סימני הטיסוי.)
Click Run to see the output here. · לחץ על הרץ כדי לראות את התוצא כאן.