当前位置:主页 > 数据库 > Mysql >

浅谈mysql可有类似oracle的nvl的函数

时间:2021-01-13 09:59:01 | 栏目:Mysql | 点击:

要用ifnull,而不是isnull

isnull是判断是否为null,返回值是1表示null或者0表示不为空

ifnull等同于oracle的nvl,用法如下

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)


isnull的用法如下

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)

您可能感兴趣的文章:

相关文章