Skip to main content

COALESCE

Checks from left to right whether NULL arguments were passed and returns the first non-NULL argument.

Syntax

COALESCE(x,...)

Arguments

ArgumentsDescription
xThe original value.

Return Type

Returns the first non-NULL argument, returns NULL if all arguments are NULL.

Examples

SELECT COALESCE(NULL, 1, 2);

+----------------------+
| COALESCE(NULL, 1, 2) |
+----------------------+
| 1 |
+----------------------+