Re: SQL "IN" operator



You cannot stick Null into the In clause. The In operator is just a
convenient short cut for writing a long series of OR clauses and as such
using NULL would effectively give you
Where [SomeField] = Null
AND nothing is ever equal to Null, not even Null.

So your criteria should be:

Where (FK In (1,2,5,7) or FK is Null)

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

"JimS" <JimS@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:12BF43ED-D109-412E-850A-7B5407B7CB3C@xxxxxxxxxxxxxxxx
I want to present a list of possible FKs in my where clause. That's simple
enough:

...WHERE FK IN (1,2,5,7)...

How do I include "NULL" values of the list? FK is a foreign key, and may
be
null if there is no matching row in the foreign table...

I want the "null" selection, if possible, to stay within the "IN" clause
for
programming convenience. If my only solution is to include an "ISNULL(FK)
AND
FK IN (1,2...)" I will, but I'd prefer it in the list.


--
Jim


.



Relevant Pages

  • Re: shrivelled/shriveled
    ... I should be writing "that". ... clause, introduced by whether, if, that. ... Any idea what the different shades of meaning are? ...
    (alt.usage.english)
  • Re: Delete Query
    ... If that fails then try using a subquery in the WHERE clause ... John Spencer ... Access MVP 2002-2005, 2007 ... Center for Health Program Development and Management ...
    (microsoft.public.access.queries)
  • Re: Diamondback bites, fails to embrace Fuctional Programming concepts
    ... > construct is to save writing those tiresome blocks of code for ... > traversing collections, why not take the next logical step and save ... The where clause does nothing of the ...
    (borland.public.delphi.non-technical)
  • Re: shrivelled/shriveled
    ... I should be writing "that". ... clause, introduced by whether, if, that. ... Any idea what the different shades of meaning are? ...
    (alt.usage.english)
  • Re: JDBC & views
    ... > I know how to do it if I am writing the select statement. ... the user specified tablethen you will have to modify the user's ... statements appropriately before submitting them to the DB. ... corresponding view names in the statement's FROM clause. ...
    (comp.lang.java.programmer)