Home >Database >SQL >Does sql between include both ends?

Does sql between include both ends?

青灯夜游
青灯夜游Original
2020-07-28 15:39:0423938browse

In SQL, the BETWEEN operator is used to select values ​​within the data range between two values. Among them, "between and" includes boundary values, that is, including both ends; "not between" does not include boundary values.

Does sql between include both ends?

SQL BETWEEN operator

The BETWEEN operator selects data between two values value within the range. These values ​​can be numeric, text, or dates.

The BETWEEN operator is usually used in conjunction with AND as the WHERE condition of the query result set.

SQL BETWEEN syntax

SELECT column_name(s)
FROM table_name
WHERE column_name BETWEEN value1 AND value2;

Example:

Data table

+----+--------------+---------------------------+-------+---------+
| id | name         | url                       | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1  | Google       | https://www.google.cm/    | 1     | USA     |
| 2  | 淘宝          | https://www.taobao.com/   | 13    | CN      |
| 3  | PHP中文网      | //m.sbmmt.com/    | 4689  | CN      |
| 4  | 微博          | http://weibo.com/         | 20    | CN      |
| 5  | Facebook     | https://www.facebook.com/ | 3     | USA     |
| 7  | stackoverflow | http://stackoverflow.com/ |   0 | IND     |
+----+---------------+---------------------------+-------+---------+

The following SQL statement selects all websites with alexa between 1 and 20:

SELECT * FROM Websites
WHERE alexa BETWEEN 1 AND 20;

Does sql between include both ends?

## Recommended related tutorials: "

Database Video Tutorial", "PHP Tutorial"

The above is the detailed content of Does sql between include both ends?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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