bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

MySQL NULLIF() Function

Concept visual

MySQL NULLIF() Function

Pointer walk
two pointers
leftright102132436485116
left=0
right=6
1
3

Start at both ends

Example

Compare two expressions:

SELECT NULLIF(25, 25);

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");

Example

Compare two expressions:

SELECT NULLIF("Hello", "world");

Example

Compare two expressions:

SELECT NULLIF("2017-08-25", "2017-08-25");

Previous

❮ MySQL Functions

Next

Previous

MySQL LAST_INSERT_ID() Function

Next

MySQL SESSION_USER() Function