Get the App
SLTechnology News&Howtos  ›  Database  › 

What are the differences between or and and in mysql

Shulou Source: shulou.com Published: 2022-05-31 12:52:16 10月04日 Update

This article will explain in detail what are the differences between or and and in mysql. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Differences: 1, there is a difference in its own meaning, or means "or", and means "and"; 2, there is a difference in function, and must meet all the conditions, while or can meet one condition.

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

When we query the data, we will use conditions to filter the data, achieve the filtering effect, filter the unwanted data, and get what we need.

The most basic is the WHERE clause query: SELECT * FROM cs_user WHERE id = 10

In this way, we can query the data with id = 10. This is a single multiple choice question like only one conditional filter.

So in a table:

For me, as long as the age (age) is between 18 and 20 (inclusive). So with the above WHERE clause, a single condition, it is difficult to get the effect we want, at this time, and and or come, English is even beginner students all understand the meaning of and and or.

AND (and) and

OR (or) or

It is not difficult to understand it, but it is very troublesome when it is used in practice and the logic may not be clear at the beginning of learning. Let's take a look:

AND:SELECT * FROM cs_user WHERE age > = 18 AND age = 18 or age = 18 should also satisfy the data of age = 18, display it, and then get the age

Tags: Conditions data differences articles queries functions only meaning clauses effects more good practical maximum clear concise successful between content writing Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Microsoft Xiaomi Shulou Tech Info