![]() |
|
|
SQL explained: What is SQL | Select Statement | Select Where | Insert | Update/Edit | Delete | Order By | Select Between SQL Statement BetweenThe 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. SELECT * FROM Members_tbl WHERE FirstName BETWEEN 'Dave' and 'Henry'
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.
Site developed by Michael Wall - Web Design Belfast N.Ireland. |
|