Skip to main content

Generate Definition Query From Selection (Data Management Tools)

Summary

Creates a definition query (in SQL format) from the selected features or rows of the layer or table.

Usage

  • An active selection on the input is required. If any selected rows are highlighted, the highlighted rows will be used to generate the query.

  • The input layer or table view must be present in the map or scene.

  • If the input layer or table is not registered with the geodatabase, a query layer will be created and the definition query will be generated from this layer.

  • A definition query clause has a limit of 1,000 values. If the selection includes more than 1,000 values, the resulting definition query will include multiple clauses.

  • When the Generation Method parameter is set to Match selection, the ObjectID field will be used by default. When a layer has a GlobalID field, this field will be used instead of the ObjectID field. The GlobalID field will not be provided in the Field parameter when the Generation Method parameter is set to Use field values.

  • The Append the active query parameter is only available if the Generation Method parameter is set to Use field values and the input layer or table has an active definition query. You can determine the active query by examining the layer or table properties.

  • When the Modify generated query parameter is checked, but the Where Clause parameter value has not been modified or specified, the tool will use the default generated definition query.

Parameters

Label Explanation Data type

Input Table

The layer or table view from which the definition query will be generated.

Table View

Generation Method

(Optional)

Specifies the method that will be used to generate the definition query.

  • Match selectionThe input table's ObjectID field (or GlobalID field if present) will be used to generate the query with values present in the selection. This is the default.

  • Use field valuesThe Field parameter value will be used to generate the query with values present in the selection.

String

Field

(Optional)

The field in the table or table view that will be used to generate values for the query. Accepted field types are Short, Long, Text, and GUID.

This parameter is required when the Generation Method parameter is set to Use field values.

Field

Query Name

(Optional)

The unique name of the query that will be generated.

String

Invert where clause

(Optional)

Specifies whether the generated definition query (where clause) will be inverted and include all unselected values or include all selected values of the input table.

  • CheckedThe where clause will be inverted.

  • UncheckedThe where clause will not be inverted. This is the default.

Boolean

Append the active query

(Optional)

Specifies whether the generated definition query will be appended to the active query.

This parameter is available when the layer or table has an active definition query and the Generation Method parameter is set to Use field values.

  • CheckedThe generated definition query will be appended to the active query.

  • UncheckedThe generated definition query will not be appended to the active query. This is the default.

Boolean

Modify generated query

(Optional)

Specifies whether the definition query will be displayed and can be modified using the Where Clause parameter before it is generated.

  • CheckedThe query can be modified before it is generated.

  • UncheckedThe query cannot be modified. This is the default.

Boolean

Where Clause

(Optional)

The generated definition query SQL expression from the other parameter values. For more information about SQL syntax, see SQL reference for query expressions used in ArcGIS.

SQL Expression

Derived output

Label Explanation Data type

Updated Table

The updated input with the generated definition query.

Feature Layer; Table View

Environments

This tool does not use any geoprocessing environments.

Licensing information

  • Basic: Yes
  • Standard: Yes
  • Advanced: Yes