The BETWEEN condition allows you to retrieve a range of values.
The syntax for between is:
| The code is as follows |
Copy Code |
SELECT columns From tables WHERE column1 between value1 and value2; |
Instance
| The code is as follows |
Copy Code |
SELECT * From suppliers WHERE supplier_id between 5000 and 5010; |
When they can be judged by other
| The code is as follows |
Copy Code |
SELECT * From suppliers WHERE supplier_id >= 5000 and supplier_id <= 5010; |
Action on a date
instance to find the data between the two dates
| The code is as follows |
Copy Code |
SELECT * From Orders WHERE order_date between To_date (' 2003/01/01 ', ' yyyy/mm/dd ') and To_date (' 2003/12/31 ', ' yyyy/mm/dd '); |
Another way
| The code is as follows |
Copy Code |
SELECT * From Orders WHERE order_date >= to_date (' 2003/01/01 ', ' yyyy/mm/dd ') and order_date <= to_date (' 2003/12/31 ', ' yyyy/mm/dd '); |
Instance three not between
| The code is as follows |
Copy Code |
SELECT * From suppliers WHERE supplier_id not between 5000 and 5500; |
Another way
| code is as follows |
copy code |
| SELECT * From suppliers WHERE supplier_id < 5000 OR supplier_id > 5500; |