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)!