Evaluation Order  Evaluation Order    • Comments 5    WHERE x <>
0 AND (8 / x) > 5  What should the result of this query be? 
Focus on the fact that we're chancing a divide-by-zero problem
with the second clause of the AND.  If this were C, C++, C#, or
Java---languages that short-circuit boolean expressions---then
the result depends on the order of execution.  Left-to-right
seems to be the universal choice, and so the result would be the
singleton 1.  We avoid the the divide-by-zero: since 0 fails the
first clause, the second is never executed.  Some languages
don't short-circuit these expressions, and so they will raise a
divide-by-zero.  Pascal is one example.  The order is still
left-to-right, but it doesn't really matter since they all get
executed.  So what actually happens in SQL?  SQL is that rare
language that does short-circuit these expressions, but in which
the order is not guaranteed.  As a result, we know this query
will either yield a singleton 1 or an error, but we don't know
which one.  This i