Parentheses in compound queries
You can use the Query builder to make precise queries containing as many rules as necessary to identify the appropriate virtual machines. In a query such as powerstate Equal "poweredOn", the result of the query is easy to predict: only the virtual machines that are turned on are included in the backup. But if several rules are combined with AND and OR, the result may not be obvious. This kind of query is called a compound query. Compound queries contain two or more rules, joined by AND, AND NOT, OR, or OR NOT.
The order in which the Query builder evaluates compound rules affects the outcome of the query. Grouping the rules with parentheses can change the order of evaluation and thus the outcome of the query.
The examples in the following table demonstrate how the Query builder evaluates compound queries with and without parentheses.
Note:
Only the Query builder's Advanced Mode supports the use of parentheses.
Table: Examples of compound queries with and without parentheses
Example query | The following virtual machines are selected |
|---|---|
HypervServer Equal "HV-serv1" OR IsClustered Equal TRUE AND powerstate Equal ON | All virtual machines in HV-serv1 (regardless of their power state), and any virtual machines that are turned on in a clustered environment. To select only the virtual machines that are turned on both in the Hyper-V server and in clustered environments, use parentheses (see next example). |
(HypervServer Equal "HV-serv1" OR IsClustered Equal TRUE) AND powerstate Equal ON | All the virtual machines that are turned on in HV-serv1 and in clustered environments. |