sql 不等于查询后 ,空值也被筛选出了如何解决!?

2025-05-10 13:18:38
推荐回答(5个)
回答1:

使用 IS NOT NULL 可以去除空值

比如
select * from table where value1 <> 'test' and value2 IS NULL
即可
其中<> 表示不等于

回答2:

先用数据库函数进行null值转换再比较:

SELECT * from 表
where not isnull(字段3,'0') = D

回答3:

还有很多搭配方式,1.where
字段3
!=
d
2.where
字段3 <>
d
3.加个条件
and
字段2
is
null

回答4:

sqlserver:
SELECT * from 表
where isnull(字段3,'') <> 'D'

oracle:
SELECT * from 表
where nvl(字段3,'') <> 'D'

mysql:
SELECT * from 表
where ifnull(字段3,'') <> 'D'

回答5:

SELECT * from 表
where 字段3 != D