Retrieval Using the AND Operator

When AND is used to connect two conditions, each conditional expression must be true for the condition to be true and the row retrieved. If any condition within a compound condition is false, the compound condition is false and the row is not selected.

For example, if you want to retrieve the records of Corporate Division Departments with a budget under $10,000 you can write the following compound condition:

DIV = 'CORP'  AND  BUDGET < 12000
In this example, AND is the logical operator.

Table here illustrates the four possible cases that can occur with the logical operator AND for the compound condition just described.

Values for Values for Condition1 Condition2
DIV BUDGET DIV='CORP' BUDGET<12000 Yields Row Result
1 CORP 10500 True True True Retrieved
2 CORP 28000 True False False Not retrieved
3 PROD 11000 False True False Not retrieved
4 PROD 27500 False False False Not retrieved

Table: Logical Operator AND

Example: Based on the above, let's develop a list of departments in the Corporate Division with a budget under $12,000.

If you enter the statement:

SELECT  DNAME, DIV, BUDGET
     FROM    DEPARTMENT
     WHERE   DIV = 'CORP' AND BUDGET < 12000 ;
the result displayed will be:

DNAME                         DIV     BUDGET
  Supplies and Procurement      CORP    10500

Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.