This Oracle tutorial explains how to use the Oracle OR condition with syntax and examples.
The Oracle OR condition is used to test multiple conditions where records are returned when any one of the conditions are met. It can be used in a SELECT, INSERT, UPDATE, or DELETE statement.
The syntax for the OR condition in Oracle/PLSQL is:
Any of the conditions can be met for the records to be selected.
The first Oracle OR condition example that we'll take a look at involves an Oracle SELECT statement with 2 conditions:
This Oracle OR condition example would return all customers that reside in either the state of California or have available_credit greater than 500. Because the * is used in the SELECT statement, all fields from the customers table would appear in the result set.
The next Oracle OR example looks at an Oracle SELECT statement with 3 conditions. If any of these conditions is met, the record will be included in the result set.
This Oracle OR condition example would return all supplier_id values where the supplier's name is either CISCO, city is New York, or offices is greater than 5.
The Oracle OR condition can be used in the Oracle INSERT statement.
For example:
This Oracle OR example would insert into the suppliers table, all account_no and name records from the customers table that reside in either New York or Newark.
The Oracle OR condition can be used in the Oracle UPDATE statement.
For example:
This Oracle OR condition example would update all supplier_name values in the suppliers table to Apple where the supplier_name was RIM or its availabe_products was less than 10.
The Oracle OR condition can be used in the Oracle DELETE statement.
For example:
This Oracle OR condition example would delete all suppliers from the suppliers table whose supplier_name was HP or its employees was greater than or equal to 60.