Syntax
NULLIF(expr1, expr2)
Purpose
If expr1 = expr2 is true, the result is NULL; otherwise, the result is expr1. This is equivalent to CASE WHEN
expr1 = expr2 THEN NULL ELSE expr1 END. Note that if the parameters are not equal, the value is expr1 in both cases.
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