The BETWEEN operator in MySQL is used to filter results within a specified range, including both boundary values. It helps simplify queries by defining lower and upper limits in a concise way.
Supports filtering for numbers, dates, and even text values within a defined range.
Improves query readability and efficiency compared to using multiple conditions.
Syntax:
SELECT column1, column2, ...
FROM table_name
WHERE column_name BETWEEN value1 AND value2;
column_name: The column on which the range condition is applied.
value1: The starting value (lower limit) of the range.
value2: The ending value (upper limit) of the range.
Working with MySQL BETWEEN Operator
Letβs look at some examples of the MySQL BETWEEN operator to understand how it works in real queries. First, we create a demo table on which the BETWEEN operator will be used: