设为首页 加入收藏

TOP

sql isnull (Oracle,mysql,mssql)
2011-06-12 21:44:33 来源: 作者: 【 】 浏览:613次 评论:0

sql isnull (oracle,mysql教程,mssql)

isnull
使用指定的替换值替换 null。

语法
isnull ( check_expression , replacement_value )

参数
check_expression

将被检查是否为 null的表达式。check_expression 可以是任何类型的。

replacement_value

在 check_expression 为 null时将返回的表达式。replacement_value 必须与

check_expresssion 具有相同的类型。

返回类型
返回与 check_expression 相同的类型。

注释
如果 check_expression 不为 null,那么返回该表达式的值;否则返回

replacement_value

示例
a. 将 isnull 与 avg 一起使用
下面的示例查找所有书的平均价格,用值 $10.00 替换 titles 表的 price 列中的

所有 null 条目。

use pubs
go
select avg(isnull(price, $10.00))
from titles
go

下面看一下其它数据库教程

oracle
oracle 没有 isnull() 函数。不过,我们可以使用 nvl() 函数达到相同的结果:

select productname,unitprice*(unitsinstock+nvl(unitsonorder,0))
from products
mysql
mysql 也拥有类似 isnull() 的函数。不过它的工作方式与微软的 isnull() 函数

有点不同。

在 mysql 中,我们可以使用 ifnull() 函数,就像这样:

select productname,unitprice*(unitsinstock+ifnull(unitsonorder,0))
from products

您看到此篇文章时的感受是:
Tags: 责任编辑:administrator
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到QQ空间
分享到: 
上一篇mysql null注意事项 下一篇mysql数据库密码忘找回办法

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

相关栏目

最新文章

图片主题

热门文章

推荐文章

相关文章

广告位