firstnonnull()

Returns the first non-NULL expression from a list of expressions. coalesce() and ifnull() are aliases.

Syntax

firstnonnull ( expression [,...] )
ifnull ( expression [,...] )
coalesce ( expression [,...] )

Parameters

expression

All expressions must be of the same datatype.

Usage

Returns the first non-NULL expression from a list of expressions. The function takes arguments of any datatype, but they must be all of the same datatype. The function returns the same datatype as its argument.

Example

firstnonnull (NULL, NULL, 'examplestring', 'teststring', NULL) returns 'examplestring'.