sajad torkamani

In a nutshell

The COALESCE function is used to return the first non-null value from a list of expressions.

Syntax

COALESCE(expression1, expression2, ..., expressionN)

Example

SELECT COALESCE(column1, column2, 'default') as result
FROM my_table;

Here, COALESCE will return the first non-null value from column1 or column2. If both are null, then 'default' is returned.

Tagged: MySQL

Leave a comment

Your email address will not be published. Required fields are marked *