ifnull
If expr1
is NULL, returns expr2. If expr1
is not NULL, returns expr1
.
Syntaxβ
ifnull(expr1,expr2);
Parametersβ
expr1
and expr2
must be compatible in data type.
Return valueβ
The return value has the same type as expr1
.
Examplesβ
mysql> select ifnull(2,4);
+--------------+
| ifnull(2, 4) |
+--------------+
| 2 |
+--------------+
mysql> select ifnull(NULL,2);
+-----------------+
| ifnull(NULL, 2) |
+-----------------+
| 2 |
+-----------------+
1 row in set (0.01 sec)