A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/sql/mysql-nullif-function/ below:

MySQL | NULLIF( ) Function

MySQL | NULLIF( ) Function

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. 


expression2 - It is used to specify the second expression. 

Return Value: 


The MySQL NULLIF() function returns NULL if both the expressions passed are equal or else it returns the first expression if both the expressions are not equal. 

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