MYSQL BETWEEN condition:
-Basically,The MYSQL BETWEEN condition specifies how to retrieve values from an expression within a specific range.
-It is used with SELECT, INSERT, UPDATE and DELETE statement.
Syntax:
WHERE expression BETWEEN value1 AND value2;
Display all record of table employee:
SELECT * FROM employee;
| emp_id |
emp_name |
department |
emp_salary |
| 1 |
Aman |
D1 |
34000 |
| 2 |
Ram |
D2 |
43000 |
| 3 |
Ramesh |
D1 |
20000 |
| 4 |
John |
D3 |
65000 |
| 5 |
Sita |
D1 |
10000 |
| 6 |
Dinesh |
D2 |
18000 |
Now Display the employee record who salary between 15000 and 60000:
SELECT * FROM employee WHERE emp_salary BETWEEN 15000 and 60000;
| emp_id |
emp_name |
department |
emp_salary |
| 1 |
Aman |
D1 |
34000 |
| 2 |
Ram |
D2 |
43000 |
| 3 |
Ramesh |
D1 |
20000 |
| 6 |
Dinesh |
D2 |
18000 |