ifnull function

Returns expr2 if expr1 is NULL, or expr1 otherwise.

Syntax

ifnull(expr1, expr2)

Arguments

  • expr1: An expression of any type.

  • expr2: An expression sharing a least common type with expr1.

Returns

The result type is the least common type of expr1 and expr2.

This function is a synonym for coalesce function.

Examples

> SELECT ifnull(NULL, array('2'));
 [2]