天天看點

oracle sql判斷值為空,Oracle,sqlserver的空值(null)判斷

Oracle,sql server的空值(null)判斷 sqlserver 替換null: isnull(arg,value) 如:selectisnull(price,0.0)fromorders,如果price為null的話,用0.0替換 與null比較: isnotnull,isnull 如select*fromorderswherepriceisnull,price等于null 如:select*fromorder

Oracle,sql server的空值(null)判斷

sql server

替換null:isnull(arg,value)

如:select isnull(price,0.0) from orders ,如果price為null的話,用0.0替換

與null比較: is not null,is null

如 select * from orders where price is null ,price等于null

如: select * from orders where price is not null , price不等于null

Oracle

替換null:nvl(arg,value)

如: select nvl(price,0.0) form orders

與null比較: is not null,is null

如 select * from orders where price is null ,price等于null

如: select * from orders where price is not null , price不等于null

在編寫sql語句時,如果要和null做比較判斷,必須使用is null 或者is not null,不能使用=null 或者!=null這種比較形式。

原因是,null是一種特殊的值,既不是0,也不是””,而表示“空”,即不存在的意思。是以,是無法像字元串和數字那樣進行比較的。is null就表示不存在,is not null就表示存在 本條技術文章來源于網際網路,如果無意侵犯您的權益請點選此處回報版權投訴 本文系統來源:php中文網