...

View Full Version : Retrieving NULL with IN Clause



Rivux
09-27-2005, 07:08 AM
How do you retrieve NULL values using the IN Clause?



SELECT table1.Column1, table1.Column2, table2.Column3
FROM table1
LEFT OUTER JOIN table2 On table1.ID = table2.ID
WHERE table2.Column3 IN (1,2,3, NULL?)


It is possible for table2.column3 to be a NULL value because the left outer join may not return a row from table2, causing the table2.column3 value to be null. Using the IN Clause, what is the syntax for including NULL values? Thanks.

nikkiH
09-27-2005, 03:06 PM
Don't use NULL in the IN.

SELECT table1.Column1, table1.Column2, table2.Column3
FROM table1
LEFT OUTER JOIN table2 On table1.ID = table2.ID
WHERE (table2.Column3 IN (1,2,3) OR table2.Column3 is null)

Rivux
09-27-2005, 04:53 PM
ah thanks, I was looking at it the wrong way. Thanks for the help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum