问题
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