You can write queries to filter features and table records to create a subset that you can then select, identify, analyze, or draw. Queries are composed of one or more clauses written in standard Structured Query Language (SQL) syntax. As an alternative to writing SQL syntax, you can optionally use the designer mode of the query builder to interactively build queries from menu choices.
Note:
See the Definition query topic for specific instructions on building clauses for definition queries of a layer or table.
Construct a query interactively
You construct a query by building one or more clauses. Follow these steps to construct a query interactively using the designer mode of the query builder.
- Right-click the layer or table in the Contents pane and click Properties
.
- In the properties window, click the Definition Query tab.
- Choose an existing query, or click the New definition query drop-down and choose Create in SQL Designer mode to build a new query.
- In the query builder, if necessary, click Add Clause
to access the menus to build a clause.
- Choose values from the drop-down menus to construct the Where clause.
These menus, and their values, are specific to the underlying source data.
- Optionally, click Verify the SQL expression is valid
to verify and add the clause to the query.
- Optionally, click Add Clause
to add another clause to the query.
- Optionally, click SQL Editor to see the query written in native SQL syntax.
Load a query
Alternatively, you can load an existing query. Hover the pointer over a definition query that is not currently being edited. Click Load to load a query from a query expression file (.exp file extension). Alternatively, in the New definition query drop down menu, click Add definition queries from files. If it is a complex expression that cannot be evaluated in designer mode, the clause opens in SQL Editor mode instead.
Modify an existing query
Once you've constructed a query from one or more clauses, there are a number of ways to modify the query. Follow any of these actions as necessary:
- The clauses in a query are always available for editing. Hover over a clause until it is highlighted. Click any of the menus of values that compose the clause and choose different values.
- To add a clause to the query, click Add Clause
.
- To remove a clause from the query, hover over the clause until it is highlighted and click Remove Clause
.
- To remove the query entirely, click Remove definition query
.
- To export the query syntax to a query expression file (.exp file extension), click Save definition query
. Browse to a file location and provide a file name.
- To replace the current query with a different query from a query expression file (.exp file extension), click Load definition query
. Browse to the file and click OK.