← CodePrimer
SQL Beginner Database

WHERE with AND / OR

How do I combine filters in SQL?

AND / OR precedence.

Sample
SELECT id, name, year_level
FROM students
WHERE year_level = 1
  AND (course = 'web1' OR course = 'web2')
ORDER BY name;

Notes

Use parentheses when mixing AND and OR.

Keywords: where · and · or · filter

Related

Need more coins?

You do not have enough coins for this action.

Your balance: 0 coins

Share