Quick Search:
Oracle PL/SQL Code Library
Find Or Post Oracle Jobs
Oracle Discussion & Chat
 Oracle PL/SQL: OR Condition Jump to:  
Category: >> Oracle PL/SQL >> OR Condition Bookmark and Share

<< 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.

Oracle Magazine
and Oracle White Papers

SQL University.net courses meet the most demanding needs of the business world for advanced education in a cost-effective manner. SQL University.net courses are available immediately for IT professionals and can be taken without disruption of your workplace schedule or processes.

Compared to traditional travel-based training, SQL University.net saves time and valuable corporate resources, allowing companies to do more with less. That's our mission, and that's what we deliver.

Click here to find out more
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 23 users online    © 2009 psoug.org

Forgot your password?