Mega Code Archive

 
Categories / MySQL Tutorial / Control Flow Functions
 

NULLIF(expr1,expr2)

Returns NULL if expr1 = expr2 is true, otherwise returns expr1. mysql> mysql> SELECT NULLIF(1,1); +-------------+ | NULLIF(1,1) | +-------------+ |        NULL | +-------------+ 1 row in set (0.00 sec) mysql> SELECT NULLIF(NULL,2); +----------------+ | NULLIF(NULL,2) | +----------------+ | NULL           | +----------------+ 1 row in set (0.00 sec)