This Oracle tutorial explains how to use the Oracle BETWEEN condition with syntax and examples.
The Oracle BETWEEN condition is used to retrieve values within a range in a SELECT, INSERT, UPDATE, or DELETE statement.
The syntax for the BETWEEN condition in Oracle/PLSQL is:
A column or calculation.
Two values that create an inclusive range that expression is compared to.
Let's look at some Oracle BETWEEN condition examples using numeric values. The following numeric example uses the BETWEEN condition to retrieve values within a numeric range.
For example:
This Oracle BETWEEN example would return all rows from the customers table where the customer_id is between 4000 and 4999 (inclusive). It is equivalent to the following SELECT statement:
Next, let's look at how you would use the Oracle BETWEEN condition with Dates. The following date example uses the BETWEEN condition to retrieve values within a date range.
For example:
This Oracle BETWEEN condition example would return all records from the order_details table where the order_date is between Feb 1, 2014 and Feb 28, 2014 (inclusive). It would be equivalent to the following SELECT statement:
The Oracle BETWEEN condition can also be combined with the Oracle NOT operator. Here is an example of how you would combine the BETWEEN condition with the NOT Operator.
For example:
This Oracle BETWEEN example would return all rows from the customers table where the customer_id was NOT between 3000 and 3500, inclusive. It would be equivalent to the following SELECT statement: