Outdated Version
You are viewing an older version of this section. View current production version.
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
select nullif(1,2);
+-------------+
| nullif(1,2) |
+-------------+
| 1 |
+-------------+
select nullif(2,2);
+-------------+
| nullif(2,2) |
+-------------+
| NULL |
+-------------+
select nullif(NULL, NULL);
+--------------------+
| nullif(NULL, NULL) |
+--------------------+
| NULL |
+--------------------+
select NULL = NULL;
+-------------+
| NULL = NULL |
+-------------+
| NULL |
+-------------+