Re: SQL ... Order of operations with Logical Operators

From: Jay Dee <ais01479_at_aeneas.net>
Date: Thu, 20 Jul 2006 01:34:03 GMT
Message-ID: <f4Bvg.30240$vl5.20347_at_tornado.ohiordc.rr.com>


FRAN wrote:
> 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
>
>
> Fran
>

It depends. I thought this was nailed down long ago, but I was amazed to learn that there is a well-known product that decided to do things differently.

Generally, we think of AND as being "tighter" than OR. IOW, A AND B OR C is the same as (A AND B) OR C. Received on Thu Jul 20 2006 - 03:34:03 CEST

Original text of this message