SQL / MySQL
Beginner
Database
· 1 min read
WHERE with AND / OR
How do I combine filters in SQL?
AND / OR precedence.
Example
SELECT id, name, year_level
FROM students
WHERE year_level = 1
AND (course = 'web1' OR course = 'web2')
ORDER BY name;
Line-by-Line Walkthrough
Use parentheses when mixing AND and OR.