Where Clause with BETWEEN Operator
It is used to fetch filtered data in a given range inclusive of two values.
Syntax:
SELECT column1,column2 FROM table_name
WHERE column_name BETWEEN value1 AND value2;
Parameter Explanation:
- BETWEEN: operator name
- value1 AND value2: exact value from value1 to value2 to get related data in result set.
To fetch records of Employees where Age is between 22 and 24 (inclusive).
Query:
SELECT * FROM Emp1 WHERE Age BETWEEN 22 AND 24;
Output:
SQL | WHERE Clause
WHERE keyword is used for fetching filtered data in a result set. It is used to fetch data according to particular criteria. WHERE keyword can also be used to filter data by matching patterns.
Syntax:
SELECT column1,column2 FROM table_name WHERE column_name operator value;
Parameter Explanation:
- column1,column2: fields in the table
- table_name: name of table
- column_name: name of field used for filtering the data
- operator: operation to be considered for filtering
- value: exact value or pattern to get related data in result