ID EN
Flow Control Functions

NULLIF(expr1,expr2)

MySQL 8.4

Returns NULL if expr1 = expr2 is true, otherwise returns expr1. This is the same as CASE WHEN expr1 = expr2 THEN NULL ELSE expr1 END.

Syntax

MYSQL
SELECT NULLIF(1,1);
NULL
SELECT NULLIF(1,2);
1

Examples

Example

The return value has the same type as the first argument.

MYSQL
SELECT NULLIF(1,1);
NULL
SELECT NULLIF(1,2);
1