Skip to main content
Version: V1.0.0

NULLIF

Declaration

NULLIF(expr1, expr2)

Description

If expr1 = expr2 is true, the return value is NULL. Otherwise, the return value is expr1. This is equivalent to CASE WHEN

expr1 = expr2 THEN NULL ELSE expr1 END. Note that if the parameters are not equal, the return value is expr1 twice.

Examples

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 (0.001 sec), 1 warning