SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Mr. & Mrs.Smith!


Mr. & Mrs.Smith!

Author
Message
VM-723206
VM-723206
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1048 Visits: 267
Comments posted to this topic are about the item Mr. & Mrs.Smith!
SanjayAttray
SanjayAttray
SSCertifiable
SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)SSCertifiable (5.8K reputation)

Group: General Forum Members
Points: 5785 Visits: 1619
Aha... This one's easy.

SQL DBA.
MattieNH
MattieNH
Hall of Fame
Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)Hall of Fame (3.8K reputation)

Group: General Forum Members
Points: 3799 Visits: 901
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



Carlo Romagnano
Carlo Romagnano
SSCertifiable
SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)SSCertifiable (7.6K reputation)

Group: General Forum Members
Points: 7614 Visits: 3401
I agreed with you. I do not like unneeded parenthesis.

I run on tuttopodismo
Tom Thomson
Tom Thomson
One Orange Chip
One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)One Orange Chip (26K reputation)

Group: General Forum Members
Points: 26371 Visits: 12506
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

kapil_kk
kapil_kk
SSCertifiable
SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)SSCertifiable (5.4K reputation)

Group: General Forum Members
Points: 5448 Visits: 2768
EASY ONE!!

_______________________________________________________________
To get quick answer follow this link:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search