images/contents.gifimages/index.gif

Chained Query Elements

By logical extension of the principles of nesting and implicit grouping, a special kind of compound query element known as a chained query element can be formed. A chained query element contains N query elements (where N is greater than 2) and N-1 identical operators, all placed in a chain within the same group. The operators must be identical so that their intrinsic precedence is equal; that ensures that the operators will be evaluated in order of appearance, from left to right. The result list produced by each operator will be used by the next operator, and so on, until all of the operators have been evaluated. A chained query element looks like the following,

q1 OP q2 OP' q3 OP'' q4

where OP, OP', and OP'' are separate instances of the exact same operator. More instances could be chained, if desired. Using parentheses to clarify the implicit grouping, and hence the relative precedence and order of evaluation, the previous example becomes:

(((q1 OP q2) OP' q3) OP'' q4)

The interior parentheses in the last example are never actually required, because they are always implied; and, when a chained query element constitutes the entire search query, no parentheses at all are needed. If, however, the chained query element will be used as a query element for another operator, then the chained query element must be explicitly enclosed in a single set of parentheses, as in the following example:

(q1 OP q2 OP' q3 OP'' q4) OP2 q5

Note: Without the enclosing parentheses, and if OP2 had a higher intrinsic precedence than OP, then the query would almost certainly produce incorrect results, because it would be interpreted as:


q1 OP q2 OP' q3 OP'' (q4 OP2 q5)