The conditions inside parentheses are evaluated first, before the ones outside.
Consider the following SQL query:
SELECT * FROM customers WHERE first_name = John AND last_name = Doe OR address_id = 2;
It could go two ways:
SELECT * FROM customers WHERE (first_name = John AND last_name = Smith) OR address_id = 2;
Here, we would get:
Customers whose first_name is John and last_name is Smith - ie all customers called John Smith
All customers (regardless of name) with address_id of 2.
SELECT * FROM products WHERE first_name = John AND (last_name = Smith OR address_id = 2);
Here, we would get:
All customers called John Smith
All customers whose first_name is John who have the same address
So, always use parentheses to ensure that conditions are evaluated in the order you intended.