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

Mr. & Mrs.Smith! Expand / Collapse
Author
Message
Posted Tuesday, April 28, 2009 11:35 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Thursday, December 11, 2014 5:11 AM
Points: 654, Visits: 267
Comments posted to this topic are about the item Mr. & Mrs.Smith!
Post #706481
Posted Wednesday, April 29, 2009 8:37 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, July 17, 2014 10:56 AM
Points: 3,924, Visits: 1,607
Aha... This one's easy.

SQL DBA.
Post #706887
Posted Friday, May 1, 2009 1:02 PM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, November 12, 2014 1:50 PM
Points: 2,670, Visits: 792
This question reminded me of something that I've never understood. You would get the same answer to the question if the where statement looked like this:

where lastname like 'Smith%'
and firstname like '%a%'
and ID in ()

that is, without the parentheses. What I don't understand is why people write code with parentheses when all the conditions are equivalent in evaluation. If all you have are ANDs or all you have are ORs, what purpose is there to putting parentheses around the individual conditions? I was taught that you only needed parentheses when you were combining ANDs and ORs. Is that true, or do all these what seem to be extra parentheses have some value?

Thanks,
Mattie



Post #708704
Posted Saturday, May 2, 2009 7:45 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Today @ 9:20 AM
Points: 2,622, Visits: 2,472
I agreed with you. I do not like unneeded parenthesis.
Post #708916
Posted Tuesday, June 16, 2009 2:54 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 4:21 PM
Points: 7,928, Visits: 9,653
Carlo Romagnano (5/2/2009)
I agreed with you. I do not like unneeded parenthesis.

I agree too, about not liking unnecessary parentheses. But I can hazard a guess as to why people do it: perhaps they first learned a language where parentheses around conditionals were mandatory (if X then Y not allowed, it has to be of (X) then Y) and/or they used languages where words like "and" and "or" were heavily overloaded ( X = a or b might mean either X = (a or b) or (X = a) or b depending on the types of X, a and b, and could actually be ambiguous for some type combinations) amnd got into the habit os using brackets all the time.

Different point: this question points up one of the stupidities of SQL: () represents a set of columns/values, except in the single case where is the empty list, in which case using it to represent a set will give you a syntax error. That's the sort of inconsistency that really irritates me (as a former language designer) - it makes the syntax slightly harder to analyse so that writing a compiler/tokenizer/interpreter is harder; and it makes the language slightly more difficult to learn; and (this is the crunch point) it sometimes makes the language quite a lot harder to generate dynamically.


Tom
Post #736053
Posted Monday, February 18, 2013 11:52 PM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 4:17 AM
Points: 1,963, Visits: 2,407
EASY ONE!!


_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Post #1421447
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse