Question · SQL and MySQL course · Module 3: Filtering (WHERE)

Parentheses and priority

Why do we use parentheses in a condition mixing AND and OR, e.g. WHERE (kategoria_id = 1 OR kategoria_id = 2) AND cena > 30 ?

Answer options

  • Parentheses are required with every WHERE condition
  • Parentheses turn AND into OR
  • Parentheses speed up the query execution
  • To state the order clearly - what is in the parentheses is evaluated first

You can check the correct answer by solving this task in the CodeWorlds game.