March 31, 2018 at 1:57 pm
Comments posted to this topic are about the item Where conditions
March 31, 2018 at 11:27 pm
Nice simple question thanks Evgeny.
...
April 2, 2018 at 7:01 am
Nice easy question, good practice - use parenthesis. Thanks.
April 2, 2018 at 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!!
LinkedIn: https://www.linkedin.com/in/sqlrv
Website: https://www.sqlrv.com
April 2, 2018 at 8:32 am
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.
April 2, 2018 at 11:36 pm
Nice one, thanks Evgeny
April 2, 2018 at 11:41 pm
Aaron N. Cutshall - Monday, April 2, 2018 7:38 AMFunny, 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