SQL BETWEEN Operator
Posted on
< Previous Next >
The SQL BETWEEN operator is used to select values within a specified range. It returns values that are within the specified range, including the endpoints.
BETWEEN Syntax
SELECT * FROM table_name
WHERE column_name BETWEEN value1 AND value2;
For Example,
SELECT * FROM student
WHERE id BETWEEN 2 AND 5;
OUTPUT

In this above example,
This query will return all the rows from the student table where the ID is between 2 and 5, inclusive. Note that the BETWEEN operator is inclusive of both the lower and upper bounds, meaning that any values that match the endpoints of the range will be included in the results.
< Previous Next >