---
title: "How do you use the BETWEEN operator in SQL to filter results based on a range of values?"  
description: "How do you use the BETWEEN operator in SQL to filter results based on a range of values?"  
author: "Revati S Misra"  
published: 2023-06-30  
updated: 2023-07-01  
canonical: https://www.mindstick.com/forum/158916/how-do-you-use-the-between-operator-in-sql-to-filter-results-based-on-a-range-of-values  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# How do you use the BETWEEN operator in SQL to filter results based on a range of values?

How do you use the BETWEEN [operator in SQL](https://www.mindstick.com/forum/160543/how-to-filter-records-using-like-operator-in-sql-server) to [filter](https://www.mindstick.com/forum/1176/filter-in-a-xml-file-in-c-sharp) [results](https://yourviews.mindstick.com/story/4497/usage-of-baking-soda-magical-results) based on a [range](https://www.mindstick.com/articles/23243/complete-troubleshooting-tips-for-belkin-n300-range-extender-setup) of [values](https://www.mindstick.com/forum/327/sum-textbox-values)?

## Replies

### Reply by Aryan Kumar

The BETWEEN [operator](https://www.mindstick.com/blog/144/union-intersection-and-except-operator-in-sql-server) in [SQL](https://www.mindstick.com/articles/13115/types-of-keys-in-sql-or-oracle-database) is used to filter results based on a range of values. The syntax for the BETWEEN operator is:

Code snippet

```plaintext
SELECT columns FROM table WHERE column_name BETWEEN low_value AND high_value;
```

- `column_name` is the name of the column that you want to filter.
- `low_value` and `high_value` are the two values that you want to use to define the range.

The BETWEEN operator is inclusive, which means that the values `low_value` and `high_value` are included in the results. For example, the following query will return all the rows from the `products` table where the price is between 10 and 20:

Code snippet

```plaintext
SELECT * FROM products WHERE price BETWEEN 10 AND 20;
```

You can also use the BETWEEN operator with dates and text values. For example, the following query will return all the rows from the `orders` table where the order date is between January 1, 2023 and April 1, 2023:

Code snippet

```plaintext
SELECT * FROM orders WHERE order_date BETWEEN '2023-01-01' AND '2023-04-01';
```

The BETWEEN operator is a versatile tool that can be used to filter results based on a range of values. It can be used with numeric, date, and text values, and it is inclusive, which means that the values that you specify are included in the results.


---

Original Source: https://www.mindstick.com/forum/158916/how-do-you-use-the-between-operator-in-sql-to-filter-results-based-on-a-range-of-values

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
