Skip to main content

IFNULL

Description​

Returns <expr1> if it is not NULL; otherwise, returns <expr2>.

Alias​

  • NVL

Syntax​

IFNULL(<expr1>, <expr2>)

Parameters​

ParameterDescription
<expr1>The first expression to check for NULL.
<expr2>The value to return if <expr1> is NULL.

Return Value​

  • Returns <expr1> if it is not NULL.
  • Otherwise, returns <expr2>.

Examples​

SELECT IFNULL(1, 0);
+--------------+
| IFNULL(1, 0) |
+--------------+
| 1 |
+--------------+
SELECT IFNULL(NULL, 10);
+------------------+
| IFNULL(NULL, 10) |
+------------------+
| 10 |
+------------------+