SQL BETWEEN Operator Example.

SQL BETWEEN Operator Example

SQL BETWEEN Operator Example

The BETWEEN operator in SQL selects values within a given range. The values can be numbers, text, or dates. It is inclusive, which means it includes the beginning and ending values in the range.

Example Usage

Consider a table named Employees with the following data:

ID Name Age
1 John Doe 28
2 Jane Smith 34
3 Emily Johnson 40

To find employees whose ages are between 30 and 35, you would use the following SQL query:

SELECT * FROM Employees
WHERE Age BETWEEN 30 AND 35;

This query will return:

ID Name Age
2 ABC Kumar 34

Explanation

The BETWEEN operator is used in the WHERE clause to filter records. It finds any values that are between 30 and 35, inclusive of both 30 and 35. Therefore, it includes Jane Smith in the results as her age matches the criteria.

Comments

Popular posts from this blog

SQL IS NOT NULL.

Database Management System