Access SQL比较在查询中不为null

问题描述

我的sql语句需要将表1中的数据字段与表2中的数据字段进行比较。当表1的数据字段为空/空时,就会出现此问题。如果我将isNull()函数放入,它将返回一堆误报。我尝试过NOT不是isNull(),但是那也不起作用。

我想要的是表1的数据字段,如果两者之间不匹配,则使用表2的数据进行更新。

        //query database and get the deleted items.
        //test data.
        List<category> itemlist = new List<category> ();
        for(int i =1; i<=100; i++)
        {
            itemlist.Add(new category() { ID = i,Name="name "+i });
        }
        var index = 0;

        while (itemlist.Count > 0)
        {
            //create transaction and remove items 
            foreach (var item in itemlist.OrderBy(c=>c.ID).Take(5))
            {
                Console.WriteLine("Remove item " + item.Name);
                itemlist.Remove(item);
            }
            index++;
            Console.WriteLine("Count " + index);
        } 

解决方法

您可以使用显式的NULL比较。我不确定您关心的是哪一列,但是像这样:

WHERE [NAVAIR Deficiencies]![Technical Data Deficiency] <> [NAVAIR_Deficiencies_Temp]![Technical Data Deficiency] OR
      [NAVAIR Deficiencies]![Technical Data Deficiency] IS NULL