要用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)
以上这篇浅谈mysql可有类似oracle的nvl的函数就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。