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

