May 20, 2008 at 9:14 am
sorry to be late getting back, but I think IN reads better, especially when other people will see the code. Easy to make mistakes with OR.
If someone says OR is better in an interview, I'd agree to disagree. My thoughts are they are the same.
the functional descriptions in BOL seem to indicate they work the same. There could potentially be a shortcut for the query optimizer if you knew that some data was likely to occur and put that first in an OR condition, but I would think putting it first in an IN condition would do the same thing.
May 20, 2008 at 2:42 pm
Steve Jones - Editor (5/20/2008)
sorry to be late getting back, but I think IN reads better, especially when other people will see the code. Easy to make mistakes with OR.If someone says OR is better in an interview, I'd agree to disagree. My thoughts are they are the same.
the functional descriptions in BOL seem to indicate they work the same. There could potentially be a shortcut for the query optimizer if you knew that some data was likely to occur and put that first in an OR condition, but I would think putting it first in an IN condition would do the same thing.
The database will generally ignore the sequence and go with the statistics anyway. And since it will all result in index/table scans anyway, the sequence won't matter much if at all.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
May 20, 2008 at 6:25 pm
If you're going to do it more than once in the same proc, make a temp table and join to it because IN, OR, and INNER JOIN are pretty much the same. Side benefit will be to allow you to change all the code from a single point should the requirements ever change.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 16 through 18 (of 18 total)
You must be logged in to reply to this topic. Login to reply