ifnull是postgresql自带的function吗?

lord_is_layuping 2010-10-11 07:49:43
ifnull是postgresql自带的function吗?

报错如下:

function ifnull(timestamp without time zone, character varying) does not exist
...全文
576 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
wwwwb 2010-10-12
  • 打赏
  • 举报
回复
POSTGRESQL没有IFNULL函数,有
COALESCE
COALESCE(value [, ...])The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display, for example:

SELECT COALESCE(description, short_description, '(none)') ...
Like a CASE expression, COALESCE only evaluates the arguments that are needed to determine the result; that is, arguments to the right of the first non-null argument are not evaluated. This SQL-standard function provides capabilities similar to NVL and IFNULL, which are used in some other database systems.

没有DateDiff对应的函数,直接相减
date '2001-10-01' - date '2001-09-28' integer '3' (days)
ACMAIN_CHM 2010-10-11
  • 打赏
  • 举报
回复
直接减就行了。
date2 - date1

结果就是天。
lord_is_layuping 2010-10-11
  • 打赏
  • 举报
回复
嗯嗯,非常感谢,ls,postgresql中有像下面这个DateDiff对应的函数吗?
DATEDIFF(date1,date2)

date1 和 date2 参数是合法的日期或日期/时间表达式。
ACMAIN_CHM 2010-10-11
  • 打赏
  • 举报
回复
[Quote=PostgreSQL 8.4.0 Documentation
]9.16.2. COALESCE
COALESCE(value [, ...])
The COALESCE function returns the first of its arguments that is not null. Null is returned only if all arguments are null. It is often used to substitute a default value for null values when data is retrieved for display, for example:

SELECT COALESCE(description, short_description, '(none)') ...
[/Quote]
ACMAIN_CHM 2010-10-11
  • 打赏
  • 举报
回复
不是PostgreSQL 自带的函数, PostgreSQL 中相同功能的函数是 COALESCE

56,679

社区成员

发帖
与我相关
我的任务
社区描述
MySQL相关内容讨论专区
社区管理员
  • MySQL
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧