SQL - SPLessons

SQL Between

Chapter 23

SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

SQL Between

SQL Between

shape Description

SQL Between operator is utilized to include both end values specified. It can be used for checking a range of values. Between operator can be used in Select, Update, Delete, Insert statements. The AND key word must be used between two limit values. The BETWEEN Condition will give back the records where expression is inside the scope of esteem-1 and esteem-2 comprehensively.

shape Conceptual
figure

SQL Between Syntax

shape Syntax

The syntax for SQL Between operator is as follows
Select * from <table_name> where <column_name> between Min and Max;

Table name =>The accurate table name in the database.

Column name =>The operations that can be performed on a column.

shape Examples

The below example describe the execution of Between operator.

sql> select * from employee;
+--------+--------+--------+
| emp_id | ename  | salary |
+--------+--------+--------+
|   1001 | Mike   |  15000 |
|   1002 | Martin |  16000 |
|   1003 | Jack   |  17000 |
|   1004 | James  |  18000 |
|   1005 | Kite   |  19000 |
+--------+--------+--------+
5 rows in set (0.00 sec)

sql> select * from employee where salary between 16000 and 18000;
+--------+--------+--------+
| emp_id | ename  | salary |
+--------+--------+--------+
|   1002 | Martin |  16000 |
|   1003 | Jack   |  17000 |
|   1004 | James  |  18000 |
+--------+--------+--------+
3 rows in set (0.00 sec)

sql> select * from employee where salary between 15000 and 17000;
+--------+--------+--------+
| emp_id | ename  | salary |
+--------+--------+--------+
|   1001 | Mike   |  15000 |
|   1002 | Martin |  16000 |
|   1003 | Jack   |  17000 |
+--------+--------+--------+
3 rows in set (0.00 sec)

By viewing the above example, the concept of Between operator will be understood.

Summary

shape Key Points

  • SQL Between Operator – Between operator is used to retrieve the values between minimum and maximum range of an expression.