mysqlcoalescenvl

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


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 ?


Solution

  • Use coalesce:

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