Home  >  Article  >  Database  >  What is the MySQL NULL-safe equality operator and how is it different from the comparison operator?

What is the MySQL NULL-safe equality operator and how is it different from the comparison operator?

王林
王林forward
2023-09-15 10:45:03735browse

什么是 MySQL NULL 安全等于运算符以及它与比较运算符有何不同?

MySQL NULL safe equals operator, equivalent to the standard SQL IS NOT DISTINCT FROM operator, performs equality comparisons similar to the = operator. Its symbol is . When we have NULL as two operands, it performs differently than the comparison operator. Consider the following example to understand NULL-safe operators and their differences from comparison operators -

mysql> Select 50 <=> 50, NULL <=> NULL, 100 <=> NULL;
+-----------+---------------+--------------+
| 50 <=> 50 | NULL <=> NULL | 100 <=> NULL |
+-----------+---------------+--------------+
|         1 |             1 |            0 |
+-----------+---------------+--------------+
1 row in set (0.00 sec)

mysql> Select 50 = 50, NULL = NULL, 100 = NULL;
+---------+-------------+------------+
| 50 = 50 | NULL = NULL | 100 = NULL |
+---------+-------------+------------+
|       1 |        NULL |       NULL |
+---------+-------------+------------+
1 row in set (0.00 sec)

The above is the detailed content of What is the MySQL NULL-safe equality operator and how is it different from the comparison operator?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete