Skip To Content

SQL query (where clause)

Queries are used in ArcGIS to select a subset of features and table records. All query expressions in ArcGIS use Structured Query Language (SQL) to formulate these search specifications. For example, you will need to use SQL when you construct a query for the Select Layer By Attribute tool.

You can enter queries in Clause mode, using buttons and lists to construct the query in easy-to-understand language. Or, if you are experienced with SQL, you can enter a statement directly in SQL mode. You can toggle between the modes by clicking the SQL button SQL button.

Learn more about building SQL queries

Clause mode

To build a query in Clause mode, click Add Clause, select a field, operator, and value or field to evaluate against, and press the Add button for that clause. As you add more clauses, you have the option to select if the clauses should be combined with exclusive (And) or additive (Or) logic. You can group or indent clauses together to build complex expressions. Using these steps in Clause mode ensures that your expression is always valid.

Building a query in Clause mode
Building a query in Clause mode

SQL mode

SQL mode provides a powerful SQL code editor with syntax help and autocompletion. If you are familiar with SQL expressions you can build a query quickly and include any operators or logic supported in SQL. Use the Verify button to make sure the expression you have written is valid.

Building a query in SQL Edit mode
Building a query in SQL mode


In this topic
  1. Clause mode
  2. SQL mode