IFNULL
Descriptionβ
Returns <expr1>
if it is not NULL
; otherwise, returns <expr2>
.
Aliasβ
- NVL
Syntaxβ
IFNULL(<expr1>, <expr2>)
Parametersβ
Parameter | Description |
---|---|
<expr1> | The first expression to check for NULL . |
<expr2> | The value to return if <expr1> is NULL . |
Return Valueβ
- Returns
<expr1>
if it is notNULL
. - Otherwise, returns
<expr2>
.
Examplesβ
SELECT IFNULL(1, 0);
+--------------+
| IFNULL(1, 0) |
+--------------+
| 1 |
+--------------+
SELECT IFNULL(NULL, 10);
+------------------+
| IFNULL(NULL, 10) |
+------------------+
| 10 |
+------------------+