Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

check for null value in MS Access SQL statement

Tags:

sql

ms-access

The following query is not returning values for CurrentVisitor in my ms access 2010 database:

SELECT h.ClientNumber, IIf(h.CheckoutDate=null,"Yes","") AS CurrentVisitor 
FROM VisitsTable AS h 
INNER JOIN (
    SELECT ClientNumber, MAX(LastVisitDate) AS LastVisitStart 
    FROM VisitsTable 
    GROUP BY ClientNumber)  
    AS t 
ON (h.LastVisitStart = t.LastVisitStart) AND (h.ClientNumber = t.ClientNumber);

I think the reason is that the check for null in the If() operation is not written correctly. Can anyone show me how to fix this?

like image 964
CodeMed Avatar asked Oct 15 '13 20:10

CodeMed


1 Answers

Use

Is Null

rather than

= Null
like image 98
Chris Rolliston Avatar answered Oct 02 '22 09:10

Chris Rolliston