Categories:

Conditional Expression Functions

NVL

If expr1 is NULL, returns expr2, otherwise returns expr1.

Aliases

IFNULL

Syntax

NVL( <expr1> , <expr2> )

Arguments

expr1

The expression to be checked to see whether it’s NULL.

expr2

If expr1 is NULL, this expression is evaluated and its value is returned.

Collation Details

Examples

Call NVL with both NULL and non-NULL values for the first expression:

SELECT NVL('food', 'bard') AS col1, NVL(NULL, 3.14) AS col2;

+------+------+
| COL1 | COL2 |
+------+------+
| food | 3.14 |
+------+------+