Building a query for the Production Advanced Query Command
A SQL expression can be defined to query features across a database. The results of the query are displayed in the table created with the Production Advanced Query Command.
SQL expressions are built according to a standard syntax, which includes
- Strings must always be enclosed within single quotes. For example:
COUNTRY = 'United States'
- Expressions are evaluated according to standard operator precedence rules. For example, the part of an expression enclosed in parentheses is evaluated before the part that is not enclosed.
- Wildcards can be used for data in file and enterprise geodatabases.
With the query builder for the Production Advanced Query Command, you can also control what is displayed in the results table aside from your expression results. You can choose to display any of the following with the results:
- Additional fields for the layers being used in your expression
- All available fields
- Field name aliases
- Start ArcMap.
- If necessary, load data in the map.
- On the main menu, click Customize > Toolbars > Production Editing.
- On the Production Editing toolbar, click Production Editing > Production Advanced Query Command.
The Production Advanced Query window appears.
Click the Advanced Query SQL button in the Production Advanced Query window.
The Select Features Using a Query dialog box appears.
- Click the Layer drop-down arrow and choose the layer or layers you want to use for your query.
Click the Method drop-down arrow and choose a selection method.
Lists of fields are displayed in the Fields and Additional display fields lists.
- Choose the field you want to use in the query in the Fields list.
Click Get Unique Values.
The unique values for the field appear.
Construct a SQL query expression.
For guidelines on how to build SQL expressions for different data formats, see About building a SQL expression.
- Click Clear to delete a previously created expression and create a new one.
Click Load and navigate to the appropriate location if you want to use a previously created query expression WHERE clause.
Only the WHERE clause will be loaded. You will still have to manually set other information, such as the layer, method, and fields.
Click Save after creating an expression if you want to save the expression for future use or reference.
Clicking Save only saves the WHERE clause but does not save other information such as layer, method, or fields.
- If you want to display any additional fields in the feature classes, check the check boxes next to their names in the Additional display fields list, or check the display all fields check box to display all available fields.
- If you want the field aliases to appear in the query table rather than the field names, check the display field alias name check box.
- If you only want to include features in the current extent, check the use current extent check box.
Do one of the following:
- Click Apply, then Close, when you have finished selecting features.
- Click OK if you want to execute the query and close the Select Features Using a Query dialog box.
The query results appear in the Production Advanced Query window.