Get the App
SLTechnology News&Howtos  ›  Database  › 

How to use the & lt;=> operator in MySQL

Shulou Source: shulou.com Published: 2022-05-31 22:23:10 09月15日 Update

This article will explain in detail how to use the "" operator in MySQL. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Question:

When I looked at the code of a former developer, I saw

? 1WHERE p.name NULL

What does the symbol mean in this query? Is it the same as the = sign? Is it still a grammatical error? But no errors or exceptions are displayed. I already know the =! = and other symbols in mysql.

Best answer:

The similarities with the = sign

Like the regular = operator, the two values are compared and the result is 0 (not equal) or 1 (equal); in other words: 0 for'A 'and 1 for' a'.

two。 The difference between the sign and the = sign

Unlike the = operator, the value of NULL is meaningless. So the = operator cannot take NULL as a valid result. So: please use the

'a 'NULL gets 0 NULL NULL and gets 1. In contrast to the = operator, the rule of the = operator is' a'=NULL, the result is NULL and even the NULL = NULL result is NULL. By the way, almost all operators and functions on mysql work this way, because comparisons with NULL are basically meaningless.

Use

When two operands may contain NULL, you need a consistent statement.

? 1...WHERE col_a?...

The placeholder here may be constant or NULL, and you don't need to make any changes to the query when using the operator.

Correlation operator

In addition, there are two other operators that handle a value for comparison with NULL, that is, IS NULL and IS NOT NULL. They are part of the ANSI standard, so they can also be used in other databases. It can only be used in mysql.

You can use it as a dialect in mysql.

? 12 NOT'IS NULL = >'a 'NULL'a' IS NOT NULL = = > NOT (' a 'NULL)

Accordingly, you can make this query field a little more portable:

? 1WHERE p.name IS NULL

This is the end of the article on "how to use MySQL" and "operator". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Tags: Operators operations operators results statements two articles queries differences meanings more symbols errors good practical effective same consistent necessary different points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information NVidia OPPO Reno vpn MySQL