nullif
Returns NULL if expr1
is equal to expr2
. Otherwise, returns expr1
.
Syntaxβ
nullif(expr1,expr2);
Parametersβ
expr1
and expr2
must be compatible in data type.
Return valueβ
The return value has the same type as expr1
.
Examplesβ
mysql> select nullif(1,2);
+--------------+
| nullif(1, 2) |
+--------------+
| 1 |
+--------------+
mysql> select nullif(1,1);
+--------------+
| nullif(1, 1) |
+--------------+
| NULL |
+--------------+