Home > Database > Mysql Tutorial > 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?

王林
Release: 2023-09-15 10:45:03
forward
773 people have browsed it

什么是 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)
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template