Construct and modify queries

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 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 in a query builder in a pane.

  1. In the query builder, if necessary, click Add Clause Add New Clause to access the menus to build a clause.
  2. Choose values from the drop-down menus to construct the Where clause. These menus, and their values, are specific to the underlying source data.
  3. Optionally click Verify the SQL expression is valid Verify the SQL expression is valid to verify and add the clause to the query.
  4. Optionally click Add Clause Add New Clause to add another clause to the query.
  5. Optionally click SQL to see the query written in native SQL syntax.

Load a query

Alternatively, you can load an existing query. Click Load Load Query to load a query from a query expression file (.exp file extension). If it is a complex expression that cannot be evaluated in the interactive mode, the clause opens in SQL 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 Add New Clause.
  • To remove a clause from the query, hover over the clause until it is highlighted and click Remove Clause Remove Clause.
  • To remove the query entirely, click Remove Query Remove.
  • To export the query syntax to a query expression file (.exp file extension), click Save Save. 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 Load Query. Browse to the file and click OK.

Related topics