SQL explained: What is SQL | Select Statement | Select Where | Insert | Update/Edit | Delete | Order By | Select Between
The SQL Between operator can be used to select a range of data between two values.
Syntax: SELECT * FROM TableName WHERE FieldName BETWEEN value1 and value2
The values can be either dates, numbers or text.
If we wanted to select all the records from our table 'Members_tbl' in
diagram 1 where the FirstName field was between 'Dave' and 'Henry' we
could use the following SQL Statement.
SELECT * FROM Members_tbl WHERE FirstName BETWEEN 'Dave' and 'Henry'
| Diagram 1 |
![]() |
If we wanted to select all the records that didn't fall into the range we could use the NOT operator as below.
SELECT * FROM Members_tbl WHERE FirstName NOT BETWEEN 'Dave' AND 'Henry'
If we had a database table called tblProducts which had a field product_names and another field product_price we could use the BETWEEN operator to retrieve all products with a price between $20 and $40. Our SQL statement below demonstrates this.
SELECT * FROM tblProducts WHERE Product_price BETWEEN 20 AND 40
The SQL Between will include the specified start and end values, so in our example above products with prices of 20 and 40 will be included.
Get the best asp web hosting provider now and save 30%
Plug and play ASP membership script that integrates with PayPal to let you charge recurring membership fees.