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