我主要有应用程序开发背景。在编程语言variable == null
或variable != null
的作品。为什么SQL语言使用IS NULL或IS NOT NULL而不是= NULL或<> NULL?
说到SQL,下面的查询不会给出任何语法错误,但也不会返回正确的结果。
select SomeColumn from SomeTable where SomeNullableColumn=null
select SomeColumn from SomeTable where SomeNullableColumn<>null
为什么我们需要编写与is null
或is not null
查询得到正确的结果?
select SomeColumn from SomeTable where SomeNullableColumn is null
select SomeColumn from SomeTable where SomeNullableColumn is not null
背后有什么is null
或is not null
代替=null
或<>null
原因/要求?
这是ANSI SQL还是Microsoft的TSQL标准?
由于'NULL'不是一个值,这意味着没有价值。你无法比较任何东西。 –
可能重复[为什么是null不等于null false](http://stackoverflow.com/questions/1833949/why-is-null-not-equal-to-null-false) – EoinS
yup重复的http:///stackoverflow.com/questions/9581745/sql-is-null-and-null –