是否有与MySQL中Oracle的NVL等效的功能? [英] Is there a function equivalent to the Oracle's NVL in MySQL?

查看:145
本文介绍了是否有与MySQL中Oracle的NVL等效的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从表中选择一列的最大值.但是有一个问题:如果表中没有行,则返回null.

I'm selecting the max of a column from a table. But there is one problem: if there are no rows in the table, it returns null.

我想使用一个函数,如果结果为null,则该函数将返回某个值.例如,对于Oracle,有NVL函数,如果该列为null,则该函数将提供特定值. MySQL中有等效的功能吗?

I want to use a function which will return a certain value if the result is null. For example with Oracle there is the NVL function which gives a certain value if the column is null. Is there an equivalent function in MySQL ?

推荐答案

使用集邮:

select coalesce(column_name, 'NULL VALUE') from the_table

这篇关于是否有与MySQL中Oracle的NVL等效的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆