Using SQL BETWEEN
SQL BETWEEN operator allows you to select a group of data in ranges of two values. These values can be numbers (integer, float),text (string) or datetime. SQL BETWEEN operator is used with SQL WHERE clause to limits the selection. Here is the syntax of using SQL BETWEEN operator:
SELECT column_list
FROM table
WHERE conditions
BETWEEN value1 AND value2
Here is an example of using SQL BETWEEN operator to select employee which has salary between 2500 and 3000:
We use the employees as a sample table as follows:
name salary
-------- -------
jack 3000.00
mary 2500.00
newcomer 2000.00
anna 2800.00
Tom 2700.00
foo 4700.00
SELECT name, salary
FROM employees
WHERE salary BETWEEN 2500 AND 3000
name salary
------ -------
jack 3000.00
mary 2500.00
anna 2800.00
Tom 2700.00
Read On