SQL语句如何写不等于?

表中允许空值。如何写“不等于”
例如:TAG字段 含:NULL、新闻、文章、......
用这个语句查询:
select * from news where Tag <> '文章'
但是结果里却不包含所有值为NULL的记录。
应该怎么写?
我知道可以用or。我想知道没有更简单的方法吗

select * from news where Tag is not '文章'

不等于:数字比较时 <>
文字比较时 is not
温馨提示:答案为网友推荐,仅供参考
第1个回答  推荐于2017-04-20
对于这种有null的我一般用这样的句子

isnull(Tag,'') <> '文章'

这样就可以搞定了
不管是字符还是数字都可以用 <>本回答被提问者采纳
第2个回答  2010-02-22
select * from news where Tag<>'文章' or Tag is null
第3个回答  2010-02-23
select * from news where rtrim(Tag) <> '文章'
相似回答