How to Use the Query Builder
The Query Builder is a machine filtering mechanism that you can use to build and save simple queries for selecting machines to include in reports. You can build queries that include or exclude machines based on hardware properties, or the presence or absence (based on installation) of specified license units or applications. You can think of queries as being similar to WHERE clauses in SQL expressions.
Queries that you build are saved to a filter. When you apply a filter that includes a query, all the other operations in the filter (for example, filtering out all machines except those in the HR department) take place first. The query is applied last.
Queries can include multiple lines (expressions), as well as AND and OR operators.
As you build a query, you select expression types, related options, and operators. The Query Builder also includes controls for adding, validating, editing, and clearing expressions.
The following lists each expression type and the type of information you can enter for each:
- License unit: Select a license unit name from the list, and then select Is Installed or Is Not Installed from the Operator list box.
- Application: Select an application name and version number from the list, and then select Is Installed or Is Not Installed from the Operator list box.
- Machine property: Select a property from the list, and then use the Operator and Value boxes to specify how the property relates to (greater than, equal to, and so on) a value you specify.
- Platform: Select Linux, Mac OS, Unix, Windows, or Unknown from the list.
AND, OR, (, ) Buttons
The following operators are intended for use in multiple-line queries:
- Use the AND button to join two or more expressions by specifying that both conditions must be met.
- Use the OR button to join two expressions to specify that one of the conditions must be met.
- Use the ( and ) buttons to enclose joined expressions, if necessary. In the absence of parentheses, expressions are evaluated in order.
See the how-to and example sections, later in this topic, to see how these work in context.
Select, Insert, and Delete LinksEach line in a query includes Select, Insert, and Delete links, which you can use to make changes to each expression.
Add, Validate, and Clear Buttons
Use these buttons as follows:
- Add: Use to add a completed expression to your query.
- Validate: Use to check the current query's syntax. If there are errors, use the Select, Insert, and Delete links to make corrections.
- Clear: Use to delete all expressions and operators from the query.
How to Build a Basic Query
A query is made up of one or more expressions, each based on the installation state of a license unit or application, or a value of a machine property. To build the basic query:
- Select the Expression type (License unit, Application, Machine property, or Platform).
- Make your selections from the displayed list boxes (which vary by expression type).
- Click the Add button to add the expression to the query.
- To make a multi-line query, use the AND and OR operator buttons. If you want to control the order in which multiple expressions are evaluated, use the ( and ) buttons.
- Click the Validate button at any time to ensure that your query is syntactically correct. Use the Select, Insert, and Delete links to make any changes.
- Click Save to add this query to the current filter, or select Save As to save the query and all other current filter settings to a new filter.
To undo your work and restore a query filter to the last saved state, select the Cancel link shown to the right of the query window. To clear the Query Builder completely, select the Clear button.
- Filter evaluation is automatically done when you save a query filter or move to another filter panel.
- You cannot switch to another panel if the current query has a syntax error.
for example, you can build a query where only machines that meet the following conditions are included in reports:
- The machine has 1 GB or greater of RAM.
- Microsoft Office Professional Plus 2016 or Microsoft Office Standard 2016 is installed.
To build this query, do the following:
In the Expression type list box, select Machine property. The Property, Operator, and Value boxes appear. From the Property list box, select RAM; from Operator, select >= (greater than or equal to); in Value, type 1 in the edit box (note that the units: in this case, GB: are shown on the right). Click the Add button.
- Click the AND button.
- Click the ( button. This is necessary to enclose both license unit expressions, because you want to select machines where either license unit is installed.
In the Expression type list box, select License unit. The Name and Operator list boxes appear. From the Name list box, select Microsoft Office Professional Plus 2016; from Operator, select Is Installed. Click the Add button.
- Click the OR button.
- In the Expression type list box, select License unit. From the Name list box, select Microsoft Office Standard 2016; from Operator, select Is Installed. Click the Add button.
- Click the ) button. This is necessary to enclose the two license unit expressions.
- Click the Validate button to verify your query's syntax. Use the Select, Insert, and Delete links to correct any syntax problems.
- When you're satisfied with the query, select Save to add this query to the current filter, or select Save As to save the query and all other current filter settings to a new filter.
Note: Remember to select the Add button after entering each expression (line) in the query, as shown in the example.
Using Wildcards with LIKE and NOT LIKE Operators
Many machine properties are stored in the database as strings. When you create a machine property expression for a string property, two of the operators you can use are LIKE and NOT LIKE. With these operators, you can use wildcards to match portions of the values of a string. The Query Builder supports the same wildcard characters as are commonly used to match file names:
- The * character is used to match zero or more characters.
- The ? character is used to match exactly one character.
for example, if you want your filter expression to evaluate the Computer Model machine property and you use the LIKE operator with a value of *dell*latitude*, any machine whose computer model property contains dell and latitude is included. Note that if you don't include wildcards in a LIKE or NOT LIKE expression, the * wildcard character is automatically assumed at the beginning and end of the string.