如何搜索至少有一列具有null值或无值的记录?

时间:2015-09-15 06:18:18

标签: sql-server-2008

我正在尝试在列列表中搜索记录,其中至少有一列具有空值或没有值。我使用下面的sql,但它只返回空值的记录,但不返回没有值的记录。

从表中选择firstname,lastname,address1,address2,postcode,其中firstname + lastname + address1 + address2 + postcode = null

感谢您提前的时间:)

1 个答案:

答案 0 :(得分:1)

select firstname, lastname, address1, address2, postcode 
from table 
where isnull(firstname,'')='' or  isnull(lastname,'') ='' or  isnull(address1,'') ='' or  isnull(address2,'')='' or  isnull(postcode,'')) =''