Just to explain further for clarification...
Your problem had to do with Operator Precedence. 'AND' has a higher precedence than 'OR', so all of the following are logically identical:
x AND y OR z
(x AND y) OR z
z OR x AND y
z OR (x AND y)
However, what you wanted was actually:
x AND (y OR z)
and in order to achieve that, you have to override the default operator precedence and force the desired grouping using parenthesis.