【发布时间】:2014-03-28 18:24:46
【问题描述】:
我在 MSSQL server 2012 中工作。我写了一个查询
select * from Mytable where col1 is not null and col1 != ''
和
select * from Mytable where col1 is not null and col1 <> ''
两者都返回相同的值。我只是想知道,<> 和 != 运算符之间的实际区别是什么?
【问题讨论】:
-
谢谢。我在stackoverflow中搜索了这个问题,但我无法得到它。所以我发布了这个问题。但是这个问题是重复的:-)
-
它们不相等,也就是说它们彼此相等...这里也有方便的替代方案:
WHERE NULLIF(col1,'') IS NOT NULL或WHERE ISNULL(col1,'') <> ''
标签: sql sql-server operators