What is the use of between in sql
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!