You are viewing an older version of this section. View current production version.
Join the SingleStore Community Today
Get expert advice, develop skills, and connect with others.

IFNULL

Returns the second argument if the first argument is NULL, else returns the first argument.

Syntax

IFNULL (val1, val2)

Arguments

  • Any SQL objects

Return Type

  • Default return type is the more general of the two given expressions, val1 and val2, in the order of: string, real, or integer.

Examples

memsql> select ifnull(NULL, 'plan b'), ifnull('plan a', 'plan b');
+------------------------+----------------------------+
| ifnull(NULL, 'plan b') | ifnull('plan a', 'plan b') |
+------------------------+----------------------------+
| plan b                 | plan a                     |
+------------------------+----------------------------+