我主要有應用程序開發背景。在編程語言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 –