If the search condition is made up of several simple conditions, they are combined by logical operators. Two logical operators: “AND” and “OR” can be used in ObjectLand .
The search condition consisting of two simple conditions combined by the logical operator “AND” is considered to be true if both simple conditions are true and it is considered false if at least one of them is false.
The search condition consisting of two simple conditions combined by the logical operator “OR” is considered true if at least one simple condition is true and it is considered false if both are false.
The last three examples from the previous subsection require search conditions containing two simple conditions. Let us clarify what logical operators should be used in each of them:
in the search condition “certificates of municipal buildings located in Sea Lane” made up of two simple conditions:
the field value “Street” is equal to the string “Sea Lane”;
the field value “Is Municipal?” is equal to “True”;
simple conditions should be combined by a logical operator “AND” since both simple conditions should be valid for every record simultaneously;
in the search condition “find and display certificates of buildings located in Sea Lane and Theatre Avenue” made up of two simple conditions:
the field value “Street” is equal to the string “Sea Lane”;
the field value “Street” is equal to the string “Theatre Avenue”;
simple conditions should be combined by a logical operator “OR” since the record is considered to satisfy the appropriate condition if at least one of them is true, that is, the building is located in Sea Lane or Theatre Avenue;
in the search condition “find and display certificates of municipal buildings repaired before 1994” comprising two simple conditions:
the field value “Is Municipal?” is equal to “True”
the field value “Date of Last Repair” should be referred to dates before 1994;
simple conditions should be combined by a logical operator “AND” since the record will satisfy the condition if the corresponding building is municipal and its date of repair is before 1.01.1994.
Use of logical operators is not limited by simple examples given above. Search condition may consist of more than two simple conditions. In this case a question about the order of evaluating simple conditions combined by different logical operators arises.
From the point of view of priority (evaluation order) logical operators “AND” and “OR” behave like arithmetic operations of multiplying and addition accordingly.
The logical operator “AND” has a higher priority than the logical operator “OR”. That is, the condition:
sc1 OR sc2 AND sc3,
where sc is a simple condition, will be calculated as
sc1 OR (sc2 AND sc3),
here, like in arithmetics, the parentheses are used to indicate the order of actions.
It means that at first evaluation of sc1 will be performed: if it is true, the whole condition will be true. If it is false, sc2 and sc3 will be evaluated, and if they are both true, the whole condition will be true.
When the parentheses are removed, priority of logical operators is taken into account and the rules similar to rules of removal of parentheses in arithmetics are applied. That is, the expression:
(sc1 OR sc2) AND sc3
is equivalent to the expression:
sc1 AND sc3 OR sc2 AND sc3.
Let's examine the search operation “find and display certificates of municipal buildings located in Sea Lane and Theatre Avenue”. The search condition for the present operation consists of three simple conditions and can be written using the logical operators in the following way:
(the field value “Street” is equal to “Sea Lane”
OR the field value “Street” is equal to “Theatre Avenue”)
AND the field value “Is Municipal?” is equal to “True”.
As the priority of the logical operator OR is lower than the priority of AND, using of parentheses is necessary in this case for correct evaluation of the condition.