表中有些字段允许为空,现在对此表查询所有记录select * from 表 where字段1 like ‘%’ and字段2 like ‘%’ ……,
怎么此字段为空的记录查不出呢?
我知道select * from 表 where isnull(字段1,’’) like ‘%’ and isnull(字段2,’’) like ‘%’ ……可以,但是每个字段都用isnull太麻烦了;
要如何才能查询出所有记录?
怎么此字段为空的记录查不出呢?
我知道select * from 表 where isnull(字段1,’’) like ‘%’ and isnull(字段2,’’) like ‘%’ ……可以,但是每个字段都用isnull太麻烦了;
要如何才能查询出所有记录?
select * from 表 where isnull(字段1,’’) like ‘%’ and isnull(字段2,’’) like ‘%’ 是把dbnull替换成了空字符所以能查出来
应该可以查出空值
对于楼主的问题,除了使用isnull(列名,''),好像没有更好的办法了,只能在where后面罗列了,例如:
where isnull(a,'') and isnull(b,'') and...
這樣嗎?