显然,ISNULL()函数和IS NULL运算符没有任何区别,并且共享一些共同的行为。我们唯一能看到的区别是它们的语法。ISNULL()函数将表达式作为其参数,而IS NULL比较运算符将表达式放在其左侧。否则,如果表达式为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)
--结束END--
本文标题: MySQL ISNULL() 函数和 IS NULL 运算符有什么区别?
本文链接: https://lsjlt.com/news/436259.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-10-23
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
2024-10-22
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0