In this tutorial you will learn about the MySQL BETWEEN Clause and its application with practical example.
The BETWEEN operator is used in combination with WHERE clause match or select a range of data value between two values.
Table Of Contents−
Syntax:
1 2 3 4 |
SELECT <field1, field2,...> FROM <table_name> WHERE <field_name> BETWEEN value1 AND value2 |
Consider “emp_info” table:
empID | empName | sale |
---|---|---|
1 | Mark | 1000 |
2 | Max | 1500 |
3 | Mark | 1800 |
5 | John | 1500 |
1 2 3 |
SELECT * FROM emp_info WHERE SALE BETWEEN 1000 AND 2000; |
Output:
empID | empName | sale |
---|---|---|
1 | Mark | 1000 |
2 | Max | 1500 |
3 | Mark | 1800 |
4 | Mark | 3000 |
5 | John | 1500 |