Quick Search:
 Oracle PL/SQL: OR Condition Jump to:  
Category: >> Oracle PL/SQL >> OR Condition  

<< lastnext >>

Snippet Name: OR Condition

Description: The OR condition allows you to create an SQL statement where records are returned when any one of the conditions are met. It can be used in any valid SQL statement - select, insert, update, or delete.

Also see:
» BETWEEN Condition
» LIKE Condition
» Combining the AND and OR Conditions
» AND Condition
» WHERE Clause: Joins
» WHERE Clause: Conditions
» Having Clause

Comment: (none)

Highlight Mode: PLSQL
Last Modified: March 07th, 2009

The syntax FOR the OR condition IS:
SELECT columns
FROM tables
WHERE column1 = 'value1'
OR column2 = 'value2';
The OR condition requires that ANY OF the conditions be must be met FOR the RECORD TO be included IN the result SET. IN this CASE, column1 has TO equal 'value1' OR column2 has TO equal 'value2'.
Example #1
The FIRST example that we'll take a look at involves a very simple example using the OR condition.
FROM suppliers
WHERE city = 'NEW York'
or city = 'Newark';
This would return all suppliers that reside in either New York or Newark. Because the * is used in the select, all fields from the suppliers table would appear in the result set.
Example #2
The next example takes a look at three conditions. If any of these conditions is met, the record will be included in the result set.
SELECT supplier_id
FROM suppliers
WHERE name = 'IBM'
or name = 'Hewlett Packard'
or name = 'Gateway';
This SQL statement would return all supplier_id values where the supplier's name IS either IBM, Hewlett Packard OR Gateway.

   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org