下面小編就為大家帶來一篇淺談mysql可有類似oracle的nvl的函數。小編覺得蠻不錯的,現在就分享給大家,也給大家做個參考。一起跟著小編過來看看吧
要用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的函數的詳情的內容,更多相關內容請關注PHP中文網(www.php.cn)!