MySQL | NULLIF( ) Function Last Updated : 19 May, 2021 Comments Improve Suggest changes Like Article Like Report 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: MySQL 5.7MySQL 5.6MySQL 5.5MySQL 5.1MySQL 5.0MySQL 4.1MySQL 4.0MySQL 3.23 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 Comment More info S Shubrodeep Banerjee Follow Improve Article Tags : SQL mysql SQLmysql Explore SQL Tutorial 7 min read BasicsWhat is SQL? 6 min read SQL Data Types 3 min read SQL Operators 5 min read SQL Commands | DDL, DQL, DML, DCL and TCL Commands 5 min read SQL Database Operations 3 min read SQL CREATE TABLE 3 min read Queries & OperationsSQL SELECT Query 2 min read SQL INSERT INTO Statement 4 min read SQL UPDATE Statement 3 min read SQL DELETE Statement 3 min read SQL - WHERE Clause 3 min read SQL | Aliases 3 min read SQL Joins & FunctionsSQL Joins (Inner, Left, Right and Full Join) 4 min read SQL CROSS JOIN 2 min read SQL | Date Functions 4 min read SQL | String functions 6 min read Data Constraints & Aggregate FunctionsSQL NOT NULL Constraint 2 min read SQL PRIMARY KEY Constraint 5 min read SQL Count() Function 7 min read SQL SUM() Function 5 min read SQL MAX() Function 4 min read AVG() Function in SQL 4 min read Advanced SQL TopicsSQL Subquery 4 min read Window Functions in SQL 6 min read SQL Stored Procedures 7 min read SQL Triggers 5 min read SQL Performance Tuning 6 min read SQL TRANSACTIONS 6 min read Database Design & SecurityIntroduction of ER Model 10 min read Introduction to Database Normalization 6 min read SQL Injection 11 min read SQL Data Encryption 5 min read SQL Backup 4 min read What is Object-Relational Mapping (ORM) in DBMS? 7 min read Like