顯然,ISNULL()函數和IS NULL運算子沒有任何區別,並且共享一些共同的行為。我們唯一能看到的差異是它們的語法。 ISNULL()函數將表達式作為其參數,而IS NULL比較運算子將表達式放在其左側。否則,如果表達式為NULL,則兩者都回傳1,如果表達式不為NULL,則傳回0。以下範例將示範上述概念−
mysql> Select 1 IS NULL; +-----------+ | 1 IS NULL | +-----------+ | 0 | +-----------+ 1 row in set (0.00 sec) mysql> Select ISNULL(1); +-----------+ | ISNULL(1) | +-----------+ | 0 | +-----------+ 1 row in set (0.00 sec) mysql> Select ISNULL(1/0); +-------------+ | ISNULL(1/0) | +-------------+ | 1 | +-------------+ 1 row in set (0.00 sec) mysql> Select 1/0 IS NULL; +-------------+ | 1/0 IS NULL | +-------------+ | 1 | +-------------+ 1 row in set (0.00 sec) mysql> Select * from Employee WHERE Salary IS NULL; +----+-------+--------+ | ID | Name | Salary | +----+-------+--------+ | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+-------+--------+ 2 rows in set (0.00 sec) mysql> Select * from Employee WHERE ISNULL(Salary); +----+-------+--------+ | ID | Name | Salary | +----+-------+--------+ | 7 | Aryan | NULL | | 8 | Vinay | NULL | +----+-------+--------+ 2 rows in set (0.00 sec)#
以上是MySQL ISNULL() 函數和 IS NULL 運算子有什麼不同?的詳細內容。更多資訊請關注PHP中文網其他相關文章!