SQL Tutorial
What is SQL SQL SELECT SQL SELECT DISTINCT SQL WHERE SQL INSERT SQL UPDATE SQL DELETE SQL AND, OR & NOT Clause SQL ORDER BY SQL LIKE Clause SQL IN Operator SQL BETWEEN Operator SQL MAX() and MIN() SQL COUNTSQL JOIN
SQL JOIN SQL INNER JOIN SQL LEFT JOIN SQL RIGHT JOIN SQL FULL OUTER JOINSQL BETWEEN Operator
The BETWEEN operator is used in the WHERE conditions to filter records within the specified range. The range of values can be strings, numbers, or dates. The range of values must be specified with the AND operator, as shown below.
Syntax:
SELECT * FROM table
WHERE column
BETWEEN begin_value AND end_value
Example Database:
This is employee table.
id | name | salary | hire date |
---|---|---|---|
1 | Kailash | 20000 | 2022-12-10 |
2 | Amit | 5000 | 2022-07-15 |
3 | Siddarth | 15000 | 2022-03-23 |
4 | Vikas | 30000 | 2022-08-20 |
BETWEEN Operator
Exmaple: The salary column is used with the BETWEEN operator to filter records. The salary BETWEEN 10000 to 20000;
specifies that the values in the salary column should be between 10000 and 20000 (inclusive of both values). The below query will display the following result.
Query:
SELECT *
FROM employee
WHERE salary BETWEEN 10000 AND 20000;
Result:
id | name | salary | hire date |
---|---|---|---|
1 | Kailash | 20000 | 2022-12-10 |
3 | Siddarth | 15000 | 2022-03-23 |
BETWEEN Date Range
Exmaple: The following query uses the BETWEEN operator to specify the date range.
Query:
SELECT *
FROM employee
WHERE salary BETWEEN '2022-07-05' and '2018-8-28';
Result:
id | name | salary | hire date |
---|---|---|---|
2 | Amit | 5000 | 2022-07-15 |
4 | Vikas | 30000 | 2022-08-20 |
Elevenstech Web Tutorials
Elevenstech Web Tutorials helps you learn coding skills and enhance your skills you want.
As part of Elevenstech's Blog, Elevenstech Web Tutorials contributes to our mission of “helping people learn coding online”.
Read More
Newsletter
Subscribe to get the latest updates from Elevenstech Web Tutorials and stay up to date