Suppose I have this statement:
SELECT * FROM MyTable WHERE a = 1 or b = 2 and c = 3
Does that mean: (a = 1) OR (b = 2 AND c = 3) or does it mean (a = 1 or b = 2) AND c = 3? Can I change what it means, i.e. execute the OR before the AND or is this not possible?
From Technet:
When more than one logical operator is used in a statement, AND operators are evaluated first. You can change the order of evaluation by using parentheses.
So yes, it means (a = 1) OR (b = 2 AND c = 3)
.
You can force the behavior you want by writing the parentheses as you did above: (a = 1 OR b = 2) AND c = 3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With