SQL BETWEEN

SQL BETWEEN can be used to select data between two values given .

Syntax

SELECT * FROM table_name  WHERE column_name BETWEEN value1 AND value2

MySQL Table – users

+—-+——+
| id | name |
+—-+——+
|  1 | PHP  |
|  2 | JS   |
|  3 | HTML |
|  5 | ASP  |
+—-+——+

Example

mysql> SELECT * FROM users WHERE id BETWEEN 2 AND 3;
+—-+——+
| id | name |
+—-+——+
|  2 | JS   |
|  3 | HTML |
+—-+——+
2 rows in set (0.00 sec)


Share