Obviously, there is no difference between theISNULL()function and theIS NULLoperator, and share some common behavior. The only difference we can see is their syntax. The ISNULL() function takes an expression as its argument, while theIS NULLcomparison operator puts the expression on its left. Otherwise, both return 1 if the expression is NULL, or 0 if the expression is not NULL. The following example will demonstrate the above concept −
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)
The above is the detailed content of What is the difference between the MySQL ISNULL() function and the IS NULL operator?. For more information, please follow other related articles on the PHP Chinese website!