Home > Database > Mysql Tutorial > What is the difference between mysql or and and

What is the difference between mysql or and and

青灯夜游
Release: 2021-12-01 15:46:14
Original
7022 people have browsed it

Difference: 1. There is a difference in meaning, or refers to "or", and refers to "and"; 2. There is a difference in function, and must satisfy all conditions, while or means to satisfy Just one condition.

What is the difference between mysql or and and

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

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

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

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

So in a table:

What is the difference between mysql or and and

If I have data, I only need data with age between 18-20 (including 18 and 20). Then using the above WHERE clause and a single condition, it is difficult to obtain the effect we want. At this time, and and or come. Even beginners in English will understand the meaning of and and or. .

AND(and) and

OR(or) or

It is not difficult to understand it, but in actual application, just When you start learning, the logic may not be clear, which can be very troublesome. Let’s take a look:

AND: SELECT * FROM cs_user WHERE age >= 18 AND age

Picture:

What is the difference between mysql or and and

Compare the cs_user table, greater than or equal to 18 and less than or equal to 20, exactly two pieces of data

OR: SELECT * FROM cs_user WHERE age >= 18 or age

Look at the picture:

What is the difference between mysql or and and

Compare AND and OR: There is no difference in the way of writing

, they There are only two biggest differences:

1. The meaning itself, and (and), or (or)

2. The difference in function

and must meet all conditions , must satisfy age >= 18 and age

or, it only needs to satisfy one of them, and it will get Obtain the data of age >= 18, display it, and then obtain age

Succinctly speaking: and must meet all conditions; or only one condition can be met

[Related recommendations: mysql video tutorial]

The above is the detailed content of What is the difference between mysql or and and. 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