mysql can have the function of nvl similar to oracle
- 2021-07-06 11:58:52
- OfStack
Use ifnull instead of isnull
isnull is used to judge whether it is null, and the return value is 1 to indicate null or 0 to indicate that it is not empty
ifnull is equivalent to nvl of oracle and is used as follows
mysql
>
select ifnull(1,10);
+--------------+
| ifnull(1,10) |
+--------------+
| 1 |
+--------------+
1 row in set (0.00 sec)
mysql
>
select ifnull(null,10);
+-----------------+
| ifnull(null,10) |
+-----------------+
| 10 |
+-----------------+
1 row in set (0.00 sec)
The usage of isnull is as follows
mysql
>
select isnull(null);
+--------------+
| isnull(null) |
+--------------+
| 1 |
+--------------+
1 row in set (0.00 sec)
mysql
>
select isnull(1);
+-----------+
| isnull(1) |
+-----------+
| 0 |
+-----------+
1 row in set (0.00 sec)