Outdated Version

You are viewing an older version of this section. View current production version.

IFNULL

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

IFNULL (val1, val2)

Arguments

  • Any SQL objects

Return Type

If the val1 is NULL, returns val2. Else returns val1.

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                     |
+------------------------+----------------------------+