检查MS Access SQL语句中的空值

时间:2013-10-15 20:41:45

标签: sql ms-access

以下查询未在我的ms access 2010数据库中返回CurrentVisitor的值:

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);

我认为原因是If()操作中的null检查未正确写入。谁能告诉我如何解决这个问题?

1 个答案:

答案 0 :(得分:19)

使用

Is Null

而不是

= Null