Create a query

You can define a query without needing to know anything about logical expressions or Structured Query Language (SQL), as ArcGIS Explorer Online presents a simple visual way of constructing and editing queries.

To create a query

  1. On the Mapping toolbar, click the Queries button The Queries buttonto show the Queries panel, and then click the + button at the bottom of the panel.
  2. In the New Query dialog box that opens, select the layer or sublayer you want to query and click OK.

    The New Query dialog box listing queryable layers in the map

  3. In the Query Definition dialog box, enter a name for the new query in the Name box.
  4. In the Query tab, fill in your query criteria:
    1. Click the Field drop-down arrow and select the field you want to query against from the list.

      The fields in the layer are listed by name, and the data type of the field is also shown; the data type affects what kind of operator you can apply in the query.

    2. Click the Operator drop-down arrow and select the logical operator for the query from the list.
      • For string fields, you can choose either Contains, Equal, or Not equal.
      • For numeric and date fields, you can choose either Equal, Greater than, Greater than or equal, Less than, Less than or equal, or Not equal.
      • For fields with domains, you can choose either Equal or Not equal.
    3. If you are querying for a value, enter the value you want to query for:
      • If you want to query for a specific value, then enter this value in the Value box.
      • If you want the user to be prompted for a value to query for, check Prompt for value check box, and enter the default value in the Value box. Also enter a Prompt and a Hint for the user when the query is executed; the Prompt will be displayed as a message in an input dialog box, and the Hint will be shown as a ToolTip for the input.

      The Query Definition dialog box shown with some query criteria added

      NoteNote:

      If you are querying a date field, you can use the Date Picker to choose a date. You can find more information on querying date fields in the section below.

      If you want to find out what the field values are, go to the Data tab to see a subset of the features in the layer and their attributes.

      If you are querying against the values in another field, select Field, click the drop-down arrow, then select the field you want to query against. You can choose a field when querying numeric and date fields.

      The Query tab showing the Field value option

    4. Click the Add button to add the criteria you have defined to the list of criteria at the bottom of the dialog box.
    5. Repeat the steps above to add another criteria to the query, if required.

      By default, if you add more than one criteria, the results of the query are those features that satisfy both criteria. You can choose instead to show features that satisfy either criteria by changing the logical operator button in the criteria list from And to Or.

      Setting the operator between criteria of a query

    6. If you want to group criteria in the query, select the criteria in the list and click the Group button at the bottom of the dialog box. Grouped criteria are shown surrounded by a box. You can also select a group of criteria and click Ungroup to remove the grouping and apply the criteria separately in the order listed.

      Grouping query criteriaUngrouping query criteria

  5. In the Display Fields tab, choose the fields that will be displayed in the Query Results panel:
    1. In the Display Field drop-down list at the top of the tab, choose the field whose values will be displayed in the Query Results panel.
    2. In the Visible Fields list, uncheck the fields that you do not want to be shown in the detailed view of the Query Results panel.

      Display Field and Visible Fields in the Query Definition dialog box

  6. Click OK to create and execute the new query.

    The Query Results panel will show all of the features that satisfy the new query, and the features will also be highlighted on the map. If you checked Prompt for value for any criteria, a dialog box is displayed where you can enter input values for the query.

    Query results shown on the map and in the Query Results panel

Querying date fields

You can perform queries on date fields to determine whether phenomena occurred on, before, or after a specific date, or within a range of dates. If you have selected a date field in the Query tab, the Date Picker button will appear at the right-hand side of the Value box, allowing you to visually choose a date using a calendar.

To specify a simple date query, click the Date Picker button and select a date in the calendar. To change the month in the date picker, click the back arrow or the forward arrow; to change the year, click the month/year string at the top of the date picker. To specify a range of dates, add two separate criteria on the same date field and select an Operator of Greater than or equal for the earliest date, and Less than or equal for the latest date you want to find.

The date picker in the Query Definition dialog box

NoteNote:

Since the format of date fields depends on the underlying geodatabase, the Query Definition dialog box includes a calendar-based date picker which allows you to select a date, then formats the date in a manner appropriate to the underlying geodatabase that is being queried. If you choose to enter a date manually, you must format the date value correctly.

Tips for defining query criteria

Use the following tips to make your queries more flexible and specific:


3/11/2013