Where conditions

  • Comments posted to this topic are about the item Where conditions

  • Nice simple question thanks Evgeny.

    ...

  • Nice easy question, good practice - use parenthesis. Thanks.

  • Funny, I was actually glad to get this one wrong!  I had always assumed that there was no order of logical precedence and therefore always preached using parenthesis correctly.  I came across an instance very much like the example and I always wondered how it just happened to produce the correct results.  Now I know, but I sure wouldn't want to rely on it!!

  • Aaron N. Cutshall - Monday, April 2, 2018 7:38 AM

    I had always assumed that there was no order of logical precedence and therefore always preached using parenthesis correctly.

    Style wise, it's always a good idea to use parentheses to disambiguate. But AND being "stickier" than OR is a pretty straightforward order of operation. That order holds in most programming languages and formal logics. There are some exceptions out there but in SQL it's well defined.

  • Nice one, thanks Evgeny

  • Aaron N. Cutshall - Monday, April 2, 2018 7:38 AM

    Funny, I was actually glad to get this one wrong!  I had always assumed that there was no order of logical precedence and therefore always preached using parenthesis correctly.  I came across an instance very much like the example and I always wondered how it just happened to produce the correct results.  Now I know, but I sure wouldn't want to rely on it!!

    The login is well set in languages like T-SQL and C#.
    However, applying parenthesis is always a good idea, making it easier to read and to transport to other languages

    ____________________________________________
    Space, the final frontier? not any more...
    All limits henceforth are self-imposed.
    “libera tute vulgaris ex”

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply