Declaration
NULLIF(expr1, expr2)
Description
If expr1 = expr2 holds true, the return value is NULL; otherwise, the return value is expr1. This is similar to the CASE WHEN
expr1 = expr2 THEN NULL ELSE expr1 END is the same. Note that if the parameters are not equal, the value obtained in both cases is expr1.
Examples
obclient> SELECT NULLIF('ABC', 123), NULLIF('123',123), NULLIF(NULL, 'abc');
+--------------------+-------------------+---------------------+
| NULLIF('ABC', 123) | NULLIF('123',123) | NULLIF(NULL, 'abc') |
+--------------------+-------------------+---------------------+
| ABC | NULL | NULL |
+--------------------+-------------------+---------------------+
1 row in set, 1 warning