Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

Logic Precedence Expand / Collapse
Author
Message
Posted Wednesday, February 12, 2014 2:20 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Yesterday @ 3:33 AM
Points: 856, Visits: 1,506
very good question for the beginners to understand what OR , AND does.

Thanks for sharing ..
Post #1540591
Posted Wednesday, February 12, 2014 3:31 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, December 12, 2014 7:15 AM
Points: 990, Visits: 819
Always add brackets when mixing operators. Even if you know the rules, brackets make a calculation less prone to misunderstanding.
Post #1540604
Posted Wednesday, February 12, 2014 3:45 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Wednesday, December 17, 2014 7:58 AM
Points: 1,007, Visits: 2,582
david.wright-948385 (2/12/2014)
Always add brackets when mixing operators. Even if you know the rules, brackets make a calculation less prone to misunderstanding.

+1
Post #1540607
Posted Wednesday, February 12, 2014 4:11 AM


SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Today @ 10:51 AM
Points: 4,158, Visits: 5,556
david.wright-948385 (2/12/2014)
Always add brackets when mixing operators. Even if you know the rules, brackets make a calculation less prone to misunderstanding.

Parenthesis prevent uncertainty (and possible misunderstanding)

Thanks for the easy one today, Steve


____________________________________________
Space, the final frontier? not any more...
All limits henceforth are self-imposed.
“libera tute vulgaris ex”
Post #1540621
Posted Wednesday, February 12, 2014 5:03 AM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Yesterday @ 12:28 PM
Points: 4,611, Visits: 4,067
It was a simple question, but nonetheless a good one. How many times have we all been tripped up somewhere and spent hours on it, only to find that the problem was something so simple that we don't even want to admit it to ourselves? Always good to keep the basics in mind, no matter how far back they get.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Post #1540654
Posted Wednesday, February 12, 2014 6:44 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: 2 days ago @ 10:22 AM
Points: 1,830, Visits: 6,646
Didn't know whether OR or AND had priority, so guessed (correctly )
It's not something I've ever really needed to know, doesn't everyone use brackets in cases like this, to make it clear what is meant?
Post #1540700
Posted Wednesday, February 12, 2014 7:29 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 7:41 PM
Points: 1,382, Visits: 1,753
david.wright-948385 (2/12/2014)
Always add brackets when mixing operators. Even if you know the rules, brackets make a calculation less prone to misunderstanding.

Until you have several layers of brackets, at which point pairing them up can become as difficult as parsing the text. This can be alleviated by formatting, e.g:
WHERE
(
(a = b)
OR
(b = c)
)
AND
(
(c = d)
OR
(
(d = e)
AND
(e = f)
)
)

as opposed to
WHERE ((a = b) OR (b 
= c)) AND ((c = d) OR (
(d = e) AND (e = f)))

The latter, of course, being the type of code outputted by Microsoft's query designers on a regular basis...
Post #1540725
Posted Wednesday, February 12, 2014 7:46 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
twin.devil (2/12/2014)
very good question for the beginners to understand what OR , AND does.

Thanks for sharing ..


Yes - and even for the experienced to remind them of the order of operations.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1540733
Posted Wednesday, February 12, 2014 7:55 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Friday, December 12, 2014 7:15 AM
Points: 990, Visits: 819
sknox (2/12/2014)
...This can be alleviated by formatting, e.g:
WHERE
(
(a = b)
OR
(b = c)
)
AND
...

as opposed to
WHERE ((a = b) OR (b = c)) AND ((c = d) OR ((d = e) AND (e = f)))


Exactly. IMHO, this goes for general query layout too.
Post #1540744
Posted Wednesday, February 12, 2014 8:02 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Yesterday @ 3:20 PM
Points: 18,064, Visits: 16,099
david.wright-948385 (2/12/2014)
sknox (2/12/2014)
...This can be alleviated by formatting, e.g:
WHERE
(
(a = b)
OR
(b = c)
)
AND
...

as opposed to
WHERE ((a = b) OR (b = c)) AND ((c = d) OR ((d = e) AND (e = f)))


Exactly. IMHO, this goes for general query layout too.


+10




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1540753
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse