In SQL Server database, the
BETWEEN operator is used to filter results based on a range of values.
The basic syntax for using the BETWEEN operator is as follows:
WHERE column_name BETWEEN value1 AND value2
In this example, the query retrieves all rows from the "table_name" table where the values in the "column_name" column are between "value1" and "value2".
BETWEEN operator is inclusive, meaning that it will include both "value1" and "value2" in the results.
For example, the following query retrieves all rows from the "orders" table where the "order_date" column is between '2022-01-01' and '2022-12-31':
WHERE order_date BETWEEN '2022-01-01' AND '2022-12-31';
SELECT * FROM employee
WHERE dep_id BETWEEN 34 AND 36;