Home > Database > Mysql Tutorial > What does <=> mean in mysql

What does <=> mean in mysql

青灯夜游
Release: 2022-01-07 11:22:26
Original
9422 people have browsed it

In mysql, "<=>" means "safe equal". It is a comparison operator, similar to the "=" equal operator, but "<=>" can be used To judge the NULL value: when both operands are NULL, the return value is 1 instead of NULL; and when one operand is NULL, the return value is 0 instead of NULL.

What does <=> mean in mysql

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

Safe equals operator (<span style="font-size: 18px;"><=></span>)

The

<=> operator is similar to the = equals operator, but <=> can be used to determine NULL values, specific syntax The rules are:

  • When both operands are NULL, the return value is 1 instead of NULL;

  • And when a When the operand is NULL, the return value is 0 instead of NULL.

##Example: Use <=> to make an equal judgment

mysql> SELECT 1<=>0,&#39;2&#39;<=>2,2<=>2,&#39;0.02&#39;<=>0,&#39;b&#39;<=>&#39;b&#39;,(1+3) <=> (2+1),NULL<=>NULL;
+-------+---------+-------+------------+-----------+-----------------+-------------+
| 1<=>0 | &#39;2&#39;<=>2 | 2<=>2 | &#39;0.02&#39;<=>0 | &#39;b&#39;<=>&#39;b&#39; | (1+3) <=> (2+1) | NULL<=>NULL |
+-------+---------+-------+------------+-----------+-----------------+-------------+
|     0 |       1 |     1 |          0 |         1 |               0 |           1 |
+-------+---------+-------+------------+-----------+-----------------+-------------+
1 row in set (0.00 sec)
Copy after login

As you can see from the result,

<=> ; has a similar function to = when performing comparison operations. The only difference is that <=> can be used to judge NULL, both of which are The return value is 1 when NULL.

[Related recommendations:

mysql video tutorial]

The above is the detailed content of What does <=> mean in mysql. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
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