Home  >  Article  >  Database  >  A brief discussion on the details of whether mysql has functions similar to oracle's nvl

A brief discussion on the details of whether mysql has functions similar to oracle's nvl

黄舟
黄舟Original
2017-03-06 13:39:121281browse

The following editor will bring you a brief discussion on whether mysql has functions similar to oracle's nvl. The editor thinks it is quite good, so I will share it with you now and give it as a reference for everyone. Let’s follow the editor and take a look.

Use ifnull instead of isnull

isnull is to determine whether it is null. The return value is 1 for null or 0 for not empty

ifnull is equivalent to Oracle's nvl, the usage is 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)


isnull is used 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)

The above is a brief discussion of the details of whether mysql can have functions similar to Oracle's nvl. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn