GIS ObjectLand. User Manual
previouscontentsnext / Tables and queries / Chapter 26. Searching records in a table

Logical operators

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:

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.

previoustopnext