SQL WHERE BETWEEN Clause
- WHERE BETWEEN returns values that fall within a given range.
- WHERE BETWEEN is a shorthand for >= AND <=.
- BETWEEN operator is inclusive: begin and end values are included.
The SQL WHERE BETWEEN syntax
The general syntax is:
- SELECT column-names FROM table-name WHERE column-name BETWEEN value1 AND value2
SQL WHERE BETWEEN Examples
1) Example of Where Between Clause
mysql> select name from person where age between 21 and 25;
+---------------+
| name |
+---------------+
| subham ball |
| sajal |
| sourav biswas |
| sajal |
| chayan das |
| monojit |
+---------------+
6 rows in set (0.01 sec)
2) Example of Where Between Clause with Distinct Clause
mysql> select distinct(name) from person where age between 21 and 25;
+---------------+
| name |
+---------------+
| subham ball |
| sajal |
| sourav biswas |
| chayan das |
| monojit |
+---------------+
5 rows in set (0.00 sec)
+---------------+
| name |
+---------------+
| subham ball |
| sajal |
| sourav biswas |
| chayan das |
| monojit |
+---------------+
5 rows in set (0.00 sec)
Comments
Post a Comment