Is there a function equivalent to the Oracle's

2020-07-02 11:48发布

问题:

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