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. · اضغط تشغيل لرؤية المخرجات هنا.