Last Updated : 19 May, 2021
The MySQL NULLIF() function is used for the comparison of two expressions. The NULLIF() function returns NULL if both the expressions are equal, else it returns the first expression. The NULLIF() function accepts the expressions as parameter and returns NULL if both of them are equal.
Syntax:
NULLIF(expression1, expression2)
Parameters Used:
expression1 - It is used to specify the first expression.
Return Value:
Supported Versions of MySQL:
Example-1: Implementing NULLIF() function by comparing two same strings.
SELECT NULLIF("Geeksforgeeks", "Geeksforgeeks");
Output:
NULL
Example-2: Implementing NULLIF() function by comparing two unequal strings.
SELECT NULLIF("123", "Geeksforgeeks");
Output:
123
Example-3: Implementing NULLIF() function by comparing two integer values.
SELECT NULLIF(2, 4);
Output:
2
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4