BETWEEN in MySQL

MySQL BETWEEN In MySQL, the BETWEEN condition is used to get values within a specific range from an expression in the SELECT, INSERT, UPDATE, and DELETE statements.

Syntax:

WHERE expression BETWEEN value1 AND value2;

Parameters:

expression: It is used to specify the column or field. value1, value2: They are used to specify the range for the values.

Example: Items table:

ID NAME QUANTITY
1 Electronics 30
2 Sports 45
3 Fashion 100
4 Grocery 90
5 Toys 50

 

Query:

SELECT *
FROM items
WHERE id BETWEEN 2 AND 4;

Output:

ID NAME QUANTITY
2 Sports 45
3 Fashion 100
4 Grocery 90
Please follow and like us:
Content Protection by DMCA.com