SQL for Smarties | SQL Programming Style | Trees and Hierarchies in SQL | SQL Puzzles and Answers | Data and Databases


Monday, July 24, 2006

SQL ... Order of operations with Logical Operators

SQL Apprentice Question
Can anyone advise how operations are treated when AND and OR are
combined?

eg


WHERE: Condition 1 > X AND Condition 2 < Y OR Condition 3 = Z


Would the result of this query be to return results that


a) Satisfied Condition 1 AND Condition 2 or alternatively, Condition 3
regarless of Conditions 1 AND 2


OR


b) Condition 1 AND Condition 2 OR Condition 1 AND Condition 3


Thanks



Celko Answers
The usual way:
parens
NOT
AND
OR

No comments: