|
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 4780
$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 | | |
| | DIV | BUDGET | DIV='PROD' | BUDGET>=28000 | Yields | Row Result |
| 1 | PROD | 32000 | True | True | True | Retrieved |
| 2 | PROD | 27500 | True | False | True | Retrieved |
| 3 | CORP | 28000 | False | True | True | Retrieved |
| 4 | CORP | 10500 | False | False | False | Not retrieved |
Table: Logical Operator OR
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
FROM DEPARTMENT
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
|
Copyright © Thunderstone Software Last updated: Sun Mar 17 21:14:49 EDT 2013
|