Is there a function equivalent to the Oracle's NVL in MySQL?

不想你离开。 提交于 2019-12-05 13:47:28

问题


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.

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 ?


回答1:


Use coalesce:

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


来源:https://stackoverflow.com/questions/7239498/is-there-a-function-equivalent-to-the-oracles-nvl-in-mysql

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!