COALESCE
Syntax
COALESCE(expr, expr, expr,...)
Description
COALESCE evaluates the expressions in order and returns the first non-NULL value. If all expressions are NULL, it returns NULL.
All expressions must be of the same type or implicitly convertible to the same type.
Examples
SELECT COALESCE(NULL,NULL,3,4,5), COALESCE(NULL,NULL,NULL);
+---------------------------+--------------------------+
| COALESCE(NULL,NULL,3,4,5) | COALESCE(NULL,NULL,NULL) |
+---------------------------+--------------------------+
| 3 | NULL |
+---------------------------+--------------------------+
1 row in set (0.001 sec)