totn MariaDB Functions

MariaDB: NULLIF Function

This MariaDB tutorial explains how to use the MariaDB NULLIF function with syntax and examples.

Description

The MariaDB NULLIF function returns NULL if two expressions are equivalent. Otherwise, it returns the first expression.

Syntax

The syntax for the NULLIF function in MariaDB is:

NULLIF( expression1, expression2 )

Parameters or Arguments

expression1 and expression2
Two expressions to test if equivalent expression1 = expression2.

Note

  • The NULLIF function will return NULL, if expression1 = expression2 (equal).
  • The NULLIF function will return expression1, if expression1 != expression2 (not equal).

Applies To

The NULLIF function can be used in the following versions of MariaDB:

  • MariaDB 10

Example

Let's look at some MariaDB NULLIF function examples and explore how to use the NULLIF function in MariaDB.

For example:

SELECT NULLIF('TechOnTheNet.com', 'TechOnTheNet.com');
Result: NULL

SELECT NULLIF('TechOnTheNet.com', 'CheckYourMath.com');
Result: 'TechOnTheNet.com'

SELECT NULLIF(32, 32);
Result: NULL

SELECT NULLIF(32, 99);
Result: 32