顯然,ISNULL()函數(shù)和IS NULL運(yùn)算符沒有任何區(qū)別,并且共享一些共同的行為。我們唯一能看到的區(qū)別是它們的語法。ISNULL()函數(shù)將表達(dá)式作為其參數(shù),而IS NULL比較運(yùn)算符將表達(dá)式放在其左側(cè)。否則,如果表達(dá)式為NULL,則兩者都返回1,如果表達(dá)式不為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)
登錄后復(fù)制
以上就是MySQL ISNULL() 函數(shù)和 IS NULL 運(yùn)算符有什么區(qū)別?的詳細(xì)內(nèi)容,更多請(qǐng)關(guān)注www.92cms.cn其它相關(guān)文章!