Home > Database > Mysql Tutorial > body text

Does mysql between and contain boundaries?

hzc
Release: 2020-06-18 12:04:33
Original
16928 people have browsed it

Does mysql between and contain boundaries?Mysql data query statement between and contains boundary values

MySQL You can use between in sql statements to limit the range of a data, for example:

select * from user where userId between 5 and 7;
Copy after login

Query users whose userIds are 5, 6, and 7. The userId range includes boundary values, which is also equivalent to the following query:

select * from user where userId >= 5 and userId <= 7;

It is mentioned in many places that between is the given range, which is greater than the first value and less than the second one value, actually this is wrong. I have always thought so before. Through experiments, the conclusion is that the boundary values ​​​​on both sides are included. If you are really unsure, you can use >= and <= to specify the conditions.

In addition, the range of not between does not include boundary values.

Recommended tutorial: "mysql tutorial"

The above is the detailed content of Does mysql between and contain boundaries?. 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