When OR is used to connect two or more conditions, the compound condition is true if any condition is true, and the row is then retireved. However, if all of the conditional expressions are false, then the row is not selected.
For example, suppose management is interested in any Product Division
department OR any department with a budget of % latex2html id marker 5608
$28,000 or greater.
This compound condition can be written as follows:
DIV = 'PROD' OR BUDGET >= 28000
In this case OR is the logical operator used.
Table here illustrates the four possible cases that can occur with the logical operator OR for the example just given.
|Values for||Values for||Condition1||Condition2|
| || || || ||Yields||Row Result|
|1|| || ||True||True||True||Retrieved|
|2|| || ||True||False||True||Retrieved|
|3|| || ||False||True||True||Retrieved|
|4|| || ||False||False||False||Not retrieved|
Example: Based on the above, let's develop a list of departments for management review, which are either in the Product Division or which have budgets of $28,000 or greater.
If you enter the statement:
SELECT DNAME, DIV, BUDGET
WHERE DIV = 'PROD' OR BUDGET >= 28000 ;
the result displayed will be:
DNAME DIV BUDGET Corporate Legal Support CORP 28000 Research and Development PROD 27500 Manufacturing PROD 32000 Customer Support and Service PROD 11000 Product Marketing and Sales PROD 25000 Strategic Planning and Intelligence INFO 28500