difference between not in and <>

  • Thread starter Thread starter sverre
  • Start date Start date
S

sverre

Hi

I wonder what the difference is between writing the condition
1) not in (2440,1042)
and
2)<> 2440 and <> 1042

I have never understood the difference but very many use "in" in SQL-syntax.

Best regards
Sverre
 
What kind of a "difference" are you looking for?

There may be some unusual scenarios where those two options could yield
different results, but I haven't run across them yet. Perhaps other
newsgroup readers can elaborate...

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Not IN (2440,1042) resolves to
NOT( =2440 Or =1042)
which can be expressed as
<> 2440 and <> 1042

So they should yield the same results. The use of Not IN (...) is just easier
to write and understand. I am pretty sure the compiler ends up with the same
query plan for either variant.

John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
 
Back
Top