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。
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 ?
我想使用一个函数,如果结果为null,它将返回一个特定的值。例如,对于Oracle,有一个NVL函数,如果列为空,它会给出一定的值。 MySQL中有相同的功能吗?
1 个解决方案
#1
16
select coalesce(column_name, 'NULL VALUE') from the_table
#1
16
select coalesce(column_name, 'NULL VALUE') from the_table