Querying by Attributes

Credits: L. Meisterlin with Moses Levich, Thiago Lee, and Erik Strand (2021)

Included in this tutorial

  • The Select by Attributes dialog

  • The Expression Builder

    • Building a qualitative query

    • Building a quantitative query

Software version in examples: ArcGIS Pro 2.8.2

Tutorial Data: The tutorial includes demonstration with sample data available here.

 

This tutorial covers constructing queries to select features in a dataset based on their attribute values.

The Select By Attributes dialogue

Access the Select by Attributes dialogue by clicking through Map > Selection > Select By Attributes on the Main Menu ribbon. Choose the layer from which to select features and the selection method from their respective dropdowns. As with interactive selection, changing the selection method allows adding to, subtracting from, or selecting from within the current selection.

the Select by Attributes dialogue box

TIP: The Select by Attributes dialogue is also available within the Attribute Table’s menu.

 

The Expression Builder

To build a query, open the Expression Builder by clicking the New Expression button in the Select by Attributes dialogue.

The Expression Builder allows you to construct queries through the user interface, building clauses from the fields and values in the layer's attribute table. Alternatively, click the SQL switch to input queries directly with SQL.

The Expression Builder also allows saving and loading query expressions.

 

Building a qualitative query

The example below demonstrates building a qualitative query to select all features from the layer called "Points1_Table1_Join" with values of "A" in the "Type_AB" field. (In other words, Type_AB = A.) To do this, we…

  • Choose the desired layer or table (Points1_Table1_Join) from the Input Rows dropdown.

  • Choose the selection type. For this example, New selection is selected in the Selection Type dropdown.

  • Build the query statement:

    • Start the query statement with the attribute field upon which the query is based, selecting it in the first dropdown. (Scroll to the field name, if necessary.) In our example, the field name is “Type_AB.”

    • Next, select the query relationship option in the second dropdown. In our example we choose is equal because we want to select only features with a specific value.

    • Choose the relevant attribute value for the selection. All unique values within the chosen field should appear in the third dropdown at the right. In our example these are "A" and "B," and we finish building the query statement by choosing "A."

    • For your reference, in our example, the full selection query is “Where Type_AB is equal 'A'.”

More complex qualitative queries can be built with multiple clauses in the Expression Builder using AND, OR, NOT, and other operators to combine selection criteria from one or many fields after clicking Add Clause. (Some are demonstrated in the next section.)

TIP: Click Apply to view the results of a query without closing the selection dialogue.

building a simple query in the Expression Builder dialogue

 

Building a quantitative query

The Expression Builder dialogue can be used to construct quantitative queries as well as more complex selections with multiple clauses.

In this example we demonstrate selecting features from Points1_Table1_Join feature class where values in the “Int_lrg” field are less than 100 (Int_lrg < 100) and values in the “Int_sm” field are not equal to 5 (Int_sm <> 5). To do this, we…

  • Choose the desired layer or table (Points1_Table1_Join) from the Input Rows dropdown.

  • Choose the selection type. For this example, New selection is selected in the Selection Type dropdown.

  • Build the query statement in two clauses:

    • In the first clause, we start by choosing the first criterion field (Int_lrg). Next we specify the query relationship (is less than) and we type the value “100” into the third field.

    • Add a second clause to the expression by clicking the Add Clause button.

    • To select features where two conditions must be true, we use the "AND" operator within the query statement by selecting AND in the first dropdown of the new clause.

    • Next, we build the second clause condition by choosing the relevant field (Int_sm), then choosing the query relationship (is not equal to), and typing the value “5” into the last field.

If we read the full expression builder dialogue as a form of sentence, the we are

Creating a new selection that includes any feature within the Points1_Table1_Join layer where the value in the the “Int_lrg” field is less than 100 and the value in the “Int_sm” field is not equal to 5.

(To see the expression in SQL, click the SQL slider. This expression should read Int_lrg < 100 And Int_sm <> 5.)

Lastly, we click Apply or OK in the Select by Attributes dialogue to execute the selection.

building a quantitative query with multiple clauses in the Expression Builder dialogue

 
Previous
Previous

Interactive Selections & Other Selection Basics

Next
Next

Querying based on Spatial Relationships