|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Saturday, April 06, 2013 12:20 AM
Points: 649,
Visits: 263
|
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Friday, March 15, 2013 2:43 PM
Points: 3,924,
Visits: 1,554
|
|
Aha... This one's easy.
SQL DBA.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 7:34 AM
Points: 2,379,
Visits: 708
|
|
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
|
|
|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Today @ 1:51 AM
Points: 1,971,
Visits: 1,821
|
|
| I agreed with you. I do not like unneeded parenthesis.
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 10:25 AM
Points: 7,091,
Visits: 7,147
|
|
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 Que conclure à la fin de tous mes longs propos? C'est que les préjugés sont la raison des sots. (Voltaire, 1756)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Sunday, May 19, 2013 11:16 PM
Points: 1,061,
Visits: 1,151
|
|
|
|
|