ansinull and comparing null fields

G

Guest

I am trying to compare two null fields in two tables.

for example:

SELECT table1.*
FROM table1, table2
WHERE table1.nullColumn= table2.nullcolumn

This returns zero records because a value of "unknown" is returned by the
WHERE clause. In SQL the 'SET ANSINULL OFF' command would fix this problem,
but Access does not accept the 'SET ANSINULL OFF' command? Any other ideas?
 
B

Brendan Reynolds

WHERE NZ(table1.nullColumn, "") = NZ(table2.nullColumn, "") (or NZ(column,0)
for numeric columns)

.... which is Access-specific, or ...

WHERE (table1.nullColumn = table2.nullColumn) OR (table1.nullColumn IS NULL
AND table2.nullColumn IS NULL)

.... which is more verbose, but generic.
 

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