Get the App
SLTechnology News&Howtos  ›  Database  › 

What is the use of between in sql

Shulou Source: shulou.com Published: 2022-05-31 23:05:39 09月18日 Update

This article is to share with you about the use of between in sql. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In sql, the BETWEEN operator is used to select values within the data range between two values. Where "between and" includes boundary values, that is, both ends; "not between" does not include boundary values.

SQL BETWEEN operator

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

The BETWEEN operator is often used in conjunction with AND as a WHERE condition for query result sets.

SQL BETWEEN syntax

SELECT column_name (s) FROM table_nameWHERE column_name BETWEEN value1 AND value2

Example:

Data sheet

+-- + | id | name | url | alexa | country | +-+-- -+ | 1 | Google | https://www.google.cm/ | 1 | USA | | 2 | Taobao | https://www.taobao.com/ | 13 | CN | | 3 | | http://www.php.cn/ | 4689 | CN | 4 | Weibo | 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 sites with alexa between 1 and 20:

SELECT * FROM WebsitesWHERE alexa BETWEEN 1 AND 20

Thank you for reading! This is the end of this article on "what is the use of between in sql?". 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, you can share it for more people to see!

Tags: Operators between data two content more articles ranges boundaries good practical both ends numeric values datasheets text articles dates conditions see knowledge Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei macOS MySQL vpn Linux