Combining Conditions with AND/OR
Real-world queries often need multiple conditions. SQL provides AND and OR to combine them.
AND - All Conditions Must Match
SELECT * FROM users WHERE condition1 AND condition2;
Both conditions must be true for a row to be included.
OR - Any Condition Can Match
SELECT * FROM users WHERE condition1 OR condition2;
A row is included if either condition is true.
Exercises
Loading exercise...
Loading exercise...
Loading exercise...
Loading exercise...
Order of Operations
Without parentheses, AND is evaluated before OR:
-- This:
WHERE a OR b AND c
-- Is interpreted as:
WHERE a OR (b AND c)
Use parentheses to make your intent clear.
Loading exercise...
Free Practice
Loading SQL editor...
Try building queries that:
- Find young users from big cities
- Find users matching several possible criteria
- Experiment with parentheses to see how they change results
التالي · الدرس 8 من 27
IN and BETWEEN Operators
قراءة 1 دقيقة
أنهيت 7 من 27 درسًا

اسأل Byte عن هذا الدرس
محادثة خاصة حول هذا الدرس. قرأ Byte الدرس كاملًا، ويجيب خلال ثوانٍ، ويُظهر القسم الذي تأتي منه كل إجابة. يمكنك السؤال بأي لغة.
الأسئلة والأجوبة
أسئلة عامة حول هذا الدرس. يجيب AI Tutor فورًا بلغتك، ويراجع فريق FreeAcademy الإجابات، ويمكن لكل المتعلمين قراءتها.

