MySQL ISNULL()函数和IS NULL运算符有什么区别?
重要的是,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运算符有什么区别? 的全部内容, 来源链接: utcz.com/z/354296.html