我有这个疑问:的SQL Server:不喜欢(<>)隐藏空值
select * from Table1 where Table1.Name <> 'John'
它返回一个没有名称=“约翰”,但预期它不返回空值的一切。我如何解决这个问题?
我有这个疑问:的SQL Server:不喜欢(<>)隐藏空值
select * from Table1 where Table1.Name <> 'John'
它返回一个没有名称=“约翰”,但预期它不返回空值的一切。我如何解决这个问题?
添加OR Table1.Name IS NULL
检查
select *
from Table1
where Table1.Name <> 'John'
OR Table1.Name IS NULL
select * from Table1 where Table1.Name is null or Table1.Name <> 'John'
这是因为空值每操作返回错误结果。尝试
where IsNull(Table1.Name, '') <> 'John'