MySQL NULLIF() Function

Example

Compare two expressions:

SELECT NULLIF(25, 25);
Try it Yourself »

Definition and Usage

The NULLIF() function compares two expressions and returns NULL if they are equal. Otherwise, the first expression is returned.

Syntax

NULLIF(expr1, expr2)

Parameter Values

Parameter Description
expr1, expr2 Required. The two expressions to be compared

Technical Details

Works in: From MySQL 4.0

More Examples

Example

Compare two expressions:

SELECT NULLIF(25, "Hello");
Try it Yourself »

Example

Compare two expressions:

SELECT NULLIF("Hello", "world");
Try it Yourself »

Example

Compare two expressions:

SELECT NULLIF("2017-08-25", "2017-08-25");
Try it Yourself »

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.