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:

  1. BETWEEN: operator name 
  2. 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:

  1. column1,column2: fields in the table
  2. table_name: name of table
  3. column_name: name of field used for filtering the data
  4. operator: operation to be considered for filtering
  5. value: exact value or pattern to get related data in result 

Similar Reads

List of Operators that Can be Used with WHERE Clause

Operator Description > Greater Than >= Greater than or Equal to < Less Than <= Less than or Equal to = Equal to <> Not Equal to BETWEEN In an inclusive Range LIKE Search for a pattern IN To specify multiple possible values for a column...

Where Clause with Logical Operators

To fetch records of  Employee with ages equal to 24....

Where Clause with BETWEEN Operator

It is used to fetch filtered data in a given range inclusive of two values....

Where Clause with LIKE Operator

It is used to fetch filtered data by searching for a particular pattern in the where clause....

Where Clause with IN Operator

It is used to fetch the filtered data same as fetched by ‘=’ operator just the difference is that here we can specify multiple values for which we can get the result set....