![]() |
Logical Disjunction |
The OR Operator |
Introduction |
Suppose a customer who is shopping, but is not ready, for a rental property comes to the office and states that she is considering renting. You show her the catalog of properties with apartments, townhouses, and single-family homes. At first glance, the customer says she cannot rent an apartment. The other two options are the townhouse or the single family. To prepare the new list, you must create a query that considers only these two options. Before building the query, you can state the following:
We can start a truth table as follows: |
To continue with this table, we can check each property. If the property is a townhouse, it is considered valid for our customer:
It a property is not a townhouse. Then, we consider the next property. If the next property is a single family, it is also valid:
When building this table, we would skip a property only if it is neither a townhouse nor a single family. In Boolean algebra, this means that if both conditions are true, the whole statement is also true. The whole statement is false only if both conditions are false. This can be resumed as follows:
This type of statement is referred to as logical disjunction. The logical disjunction is expressed in Microsoft Access and in SQL with the OR operator.
Once again, consider our list of videos: Imagine that you want to see a list of the movies that either were released in 1994 or are rated PG-13. If a movie was released in 1994, the whole statement is true, regardless of the second condition. If a movie of our collection is rated PG-13, the whole statement is true even if the movie was released in a year other than 1994. The statement is also true if both conditions are met. On the other hand, if a movie was released in a year other than 1994 and it is not rated PG-13, then the whole statement is false. As done for the logical conjunction, before applying a logical disjunction to a table, a query in Datasheet View or a form in Form View, first display it in Filter By Form: While in the Look For tab, click the box under the column that would be used to set the first condition, and select the desired value: After selecting the value of the first condition, click the Or tab in the lower left section of the window. Click the arrow of the combo box under the column that would be used as the second condition: After setting the criteria, click the Apply Filter button:
When creating a query in Design View, the window provides two convenient sections for the first and the second conditions. To set the first condition, click the Criteria box corresponding to its column and type the operation. To set the second condition, click the Or box corresponding to its column and enter the necessary condition. Here is an example: |
|
|
|
||
Previous | Copyright © 2005-2016, FunctionX | Next |
|