Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NOT IN vs. <> 1

Status
Not open for further replies.

kermitforney

Technical User
Joined
Mar 15, 2005
Messages
374
Location
US
Anyone have any info or a link to an article that explains best practices or a comparison for NOT IN and <> (not equal to)??

Thanks!! :oD
 
Well, they are completely different. NOT IN compares against a list of values whereas <> compares one value versus another single value.
 
Well, I am asking because I have a query and I am gauging performance. The end of my WHERE clause criteria is, "AND table.column NOT IN (56)". I have been testing the speed and using NOT IN instead of "<> 56" is much faster. The results for NOT IN are very consistent while the results for <> are all across the board. Not sure why this is, but it is. :o/
 
I've never seen that behavior personally. Do they produce the same execution plans?
 
Same exact plans. Weird . . thinking it may be order precedence and decreasing the size of a result set. I dunno, but i do know I have to get back to work and stop thinking about this. :o)

Thanks, River!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top