WHERE clause for a NULL/Empty field

N

Nicola M

Hi all! Access 2003.
I'm not able to set WHERE clause properly to do the following:
Field1, Field2, Field3 are all Date/Time fields. 1 and 2 are always filled.
3 is filled only after a precise data that can be , but not necesserily is,
the same of 2. I need a SQL statement tha perform a double check. In
pseudo-code language the task is
IF 3 = NULL OR 3 = Empty then
show records WHERE date is <= 2
ELSE
show records WHERE date <= 3
END IF
I tried with IS NULL, IS NOT NULL, IS EMPTY but I receive always an error.
Please thanks for any advice, tips or suggestion.

Nicola M
 
R

Rick Brandt

Hi all! Access 2003.
I'm not able to set WHERE clause properly to do the following: Field1,
Field2, Field3 are all Date/Time fields. 1 and 2 are always filled. 3 is
filled only after a precise data that can be , but not necesserily is,
the same of 2. I need a SQL statement tha perform a double check. In
pseudo-code language the task is
IF 3 = NULL OR 3 = Empty then
show records WHERE date is <= 2
ELSE
show records WHERE date <= 3
END IF
I tried with IS NULL, IS NOT NULL, IS EMPTY but I receive always an
error. Please thanks for any advice, tips or suggestion.

Nicola M

Is Null is the correct usage. I think this should do what you want...

SELECT *
FROM TableName
WHERE (Date2 >= Date() AND Date3 Is Null)
OR (Date3 >= Date())
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top