
1886 Lynwood Drive/Concord, CA 94519
Telephone: (415) 735-7504
Parentheses
You can use parentheses to indicate the order for evaluating connectors in a
query. If you have more than two query rules and have selected at least one
OR operator, you may need to add parentheses to make sure that you are
getting the desired result.
For example, the following query consists of two selection rules telling the
system to select the records for all cars with the initials of XYZ and the
car number greater then 5000.
include all records where
INIT is equal to "XYZ"
AND NUMBER is greater then 5000
Because the selection rules are joined by "and," the system will retrieve
records that satisfy the requirements of both rules. If these rules were
joined by "or" instead, the system would retrieve all records that satisfy
either rule; that is, records in which the value of INIT is "XYZ" or the value
of NUMBER is 5000 or higher.
However, if you have more then two rules and have used both AND and OR
operators, then you should add parentheses to make sure that you are
getting the desired result.
Let's return to the above example and say that we wnat to change our list so
that we see car initials equal to XYZ where the car number is over 5000 or
the SPLC is equal to 123456. So we append a new rule:
Include all records where
INIT is equal to "XYZ"
AND NUMBER is greater than 5000
OR SPLC is equal to 123456
Without any extra parentheses, the connectors are evaluated in the order that
they are listed. So what we get are records where cars with initials equal
XYZ and car numbers greater than 5000 and records where the SPLC is equal to
123456.
To get what we really want, we need to add extra parentheses to group the
second and third rules so that the OR happens before the AND. In the second
rule we add a ( to the left parenthesis box and in the third rule we add a )
to the right parenthesis box.
Our query then becomes
INIT is equal to "XYZ"
AND ( NUMBER is greater than 5000
OR SPLC is equal to 123456 )
The connectors within parentheses are evaluated first, from the innermost
level of parentheses outward, and from left to right within any set of
parentheses. So first we find those records that have a car number greater
then 5000 or SPLC = 123456 and then AND that results so that the INIT must
be XYZ.
To place parentheses in a selection rule, place the edit cursor in the left or
right parentheses edit box and type one or more parentheses.
If you are using partentheses, you can enter them in any of your query rules.
However, the total number of left parentheses must match the total number of
right parentheses or when you try to OK or Verify the query, you will get an
"Unbalanced parentheses" error.