Bentley SewerGEMS CONNECT Edition Help

Creating Queries

A query is a valid SQL expression that you construct in the Query Builder dialog box. You create and manage queries in the Queries Manager. You also use queries to filter FlexTables and as the basis for a selection set.

To create a query from the Queries Manager:

  1. Open the Queries Manager by clicking View > Queries.
  2. Perform one of the following steps:
  3. To create a new hydraulic model query, highlight Queries - Hydraulic Model in the list pane, then click the New button and select Query.
  4. To create a new shared query, highlight Queries - Shared in the list pane, then click the New button and select Query. You can also right-click an existing item or folder in the list pane and select New > Query from the shortcut menu.
  5. In the Select Element Type dialog box, select the desired element type from the drop-down menu. The Query Builder dialog box appears.
  6. All input and results fields for the selected element type appear in the Fields list pane, available SQL operators and keywords are represented by buttons, and available values for the selected field are listed in the Unique Values list pane. Perform the following steps to construct your query:
  7. Double-click the field you wish to include in your query. The database column name of the selected field appears in the preview pane.
  8. Click the desired operator or keyword button. The SQL operator or keyword is added to the SQL expression in the preview pane.
  9. Click the Refresh button above the Unique Values list pane to see a list of unique values available for the selected field. Note that the Refresh button is disabled after you use it for a particular field (because the unique values do not change in a single query-building session).
  10. Double-click the unique value you want to add to the query. The value is added to the SQL expression in the preview pane. You can also manually edit the expression in the preview pane.
  11. Check the Validate box above the preview pane to validate your SQL expression when the query is applied.
  12. Click the Apply button above the preview pane to execute the query. If the expression is valid, the word "VALIDATED" is displayed in the lower right corner of the dialog box.
  13. Click OK.


  1. Perform these optional steps in the Queries Manager:
  2. To create a new folder in the tree view, highlight the existing item or folder in which to place the new folder, then click the New button and select Folder. You can create queries and folders within folders.
  3. To delete an existing query or folder, click the Delete button. When you delete a folder, you also delete all of its contents (the queries it contains).
  4. To rename an existing query or folder, click the Rename button, then type a new name.
  5. To edit the SQL expression in a query, select the query in the list pane, then click the Edit button. The Query Builder dialog box appears.
  6. To quickly select all the elements in the drawing pane that are part of the currently highlighted query, click the Select in Drawing button.

Query Builder Dialog Box

You construct the SQL expression that makes up your query in the Query Builder dialog box. The Query Builder dialog box is accessible from the Queries Manager and from within a FlexTable.

The top part of the dialog box contains all the controls you need to construct your query: a list pane displaying all available attributes for the selected element type, a SQL control panel containing available SQL keywords and operators, and list view that displays all the available values for the selected attribute. The bottom part of the dialog box contains a preview pane that displays your SQL expression as you construct it.

All the dialog box controls are described in the following table.

  Fields Lists all input and results fields applicable to the selected element type. This list displays the labels of the fields, while the underlying database column names of the fields become visible in the preview pane when you add them to the expression. Double-click a field to add it to your SQL expression.
  SQL Controls These buttons represent all the SQL operators and controls that you can use in your query. They include = , > , < , _ , ? , * , <> , >= , <= , [ ] , Like , And , and Or . Click the appropriate button to add the operator or keyword to the end of your SQL expression, which is displayed in the preview pane.
  Unique Values When you click the Refresh button, this list displays all the available unique values selected field. Double-click a value in the list to add it to the end of your SQL expression, which is displayed in the preview pane. If you select a different field, you must click the Refresh button again to update the list of unique values for the selected field. When you first open the Query Builder dialog box, this list is empty.
Refresh Updates the list of unique values for the selected field. This button is disabled after you use it for a particular field.
Copy Copies the entire SQL expression displayed in the preview pane to the Windows clipboard.
Paste Pastes the contents of the Windows clipboard into the preview pane at the location of the text cursor. For example, if your cursor is at the end of the SQL expression in the preview pane and you click the Paste button, the contents of your clipboard will be added to the end of the expression.
Validate Validates the SQL expression in the preview pane. If the expression is not valid, a message appears. When you click this button and your SQL expression passes validation, the word "VALIDATED" appears in the lower right corner of the dialog box.
Apply Executes the query. The results of the query are displayed at bottom of the Query Builder dialog box in the form “ x of x elements returned.”
  Preview Pane Displays the SQL expression as you add fields, operators and/keywords, and values to it.