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

NULLIF

Returns NULL if the arguments are equal, otherwise the first argument.

Syntax

NULLIF (val1, val2)

Arguments

  • Any SQL objects

Return Type

The return value has the same type as the first argument, or NULL.

Examples

memsql> select nullif(1,2);
+-------------+
| nullif(1,2) |
+-------------+
|           1 |
+-------------+

memsql> select nullif(2,2);
+-------------+
| nullif(2,2) |
+-------------+
|        NULL |
+-------------+

memsql> select nullif(NULL, NULL);
+--------------------+
| nullif(NULL, NULL) |
+--------------------+
| NULL               |
+--------------------+

memsql> select NULL = NULL;
+-------------+
| NULL = NULL |
+-------------+
|        NULL |
+-------------+