Home > Database > Mysql Tutorial > body text

What are operators in MySQL?

PHPz
Release: 2023-08-31 11:57:02
forward
1110 people have browsed it

What are operators in MySQL?

The following is the usage of operator in MySQL.

Case 1

This operator is similar to the = operator, that is, the result will be true(1) when the values ​​are equal, otherwise it will be false(0).

In the first case, the = and operators work the same.

Case 2

Whenever we compare any value with NULL, operator gives value 0 and when we compare with NULL NULL, it returns 1.

And in the case of = operator, this does not happen. Whenever we compare any value with NULL, it returns NULL. If we compare NULL with NULL, only NULL is returned.

Here are examples of the two situations above. The query is as follows -

mysql> SELECT 10 <=> 10, NULL <=> NULL, 10 <=> NULL;
Copy after login

This is the output.

+-----------+---------------+-------------+
| 10 <=> 10 | NULL <=> NULL | 10 <=> NULL |
+-----------+---------------+-------------+
|         1 |              1|            0|
+-----------+---------------+-------------+
1 row in set (0.00 sec)
Copy after login

Look at the output above, NULL <=> NULL returns 1, not NULL.

Now let’s look at an example of the = operator. The query is as follows -

mysql> SELECT 10 = 10, NULL = NULL, 10 = NULL;
Copy after login

This is the output.

+---------+-------------+-----------+
| 10 = 10 | NULL = NULL | 10 = NULL |
+---------+-------------+-----------+
|       1 |        NULL |      NULL |
+---------+-------------+-----------+
1 row in set (0.00 sec)
Copy after login

Look at the above output, NULL = NULL returns NULL.

The above is the detailed content of What are operators in MySQL?. 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