How to use the Query Tool

The query tool is designed to allow you to select a subset of features from the active layer based on your own criteria. By default, one of the map layers is always active. To make a layer active, click the radio button next to the layer's name in the layer list.

To run a query, first build a logical query by using the form that is shown in the bottom-center of the screen. Then add it to a query string and execute this query. This is a multi-step process, described below.

Note: It may be helpful to resize this page above the query form, so that you can read these instructions and simultaneously test them out on the form.

1.) Choose a field from the active layer by using the drop-down list under 'field'. Fields are attributes of the active layer. For example, in the streams layer there is a field called 'Name' that contains the name of the stream, and another field named 'Tributary To' that contains the name of the stream that the stream is a tributary of. Clicking the field in the drop down list will register it in the field box.

2.) Choose an operator with the drop down list to the right of field. For text fields, the only applicable operators will be '=' and 'like'. The 'like' operator allows you to search for a string within an attribute if you don't know the exact attribute. The '%' symbol is used in conjunction with the like operator to do this. For example, you might be looking for a stream that contains the word 'Harvey' but are not sure of the exact name (Harvey Creek, Harvey Gulch, North Harvey Creek, etc.) Querying for 'stream like %Harvey%' will check for different variations of the name. For numeric fields, the applicable operators are '=', '<', '>', '<=', or '>='.

3.) Enter a value in the next box, under 'value'. This is the string or number that you are looking for in the field. It is not necessary to include quotations for text strings, as they will be added automatically by the application.

4.) Click the 'Add to Query String' button to add your query statement. The query statement is composed of the field + the operator + the value. Some examples of queries that could be created are:

Streams Layer:

Tributary to = John Day River (selects all streams that are tributaries to the John Day River)

Name like %zigzag% (selects all streams that contain the word 'zigzag' somewhere in their name)

Hatcheries Layer:

Fish Type like %anadromous% (selects all hatcheries that are known to raise anadromous fish)

FTEStaff > 8 (selects all hatcheries that are known to have more than 8 full time staff)

5.) More complicated queries can also be made using and/or/not within the query string. When these buttons are clicked, the corresponding words are added to the query statement at the bottom of the screen. For example, if you just composed the query of hatcheries where 'FTE Staff > 8' and wish to further refine it to only include hatcheries that are federal, this could be done by first adding the initial query to the statement by composing it and clicking 'add to query string'. Next, click the 'and' button to add 'and' to the query statement, and finally compose a second query where 'type = federal' and click the 'add to query string' button to add this to the query statement. The query 'ftestaff > 8 and type = federal' is therefore searching for hatcheries with more than 8 full-time staff that are federally managed. The 'or' condition works in the same way, but is logically more inclusive rather than exclusive. The 'not' statement may be used to query for features where a given condition is not true. For example, with an ESU layer, the statement 'Not Status = threatened' will select all ESU areas where the given species is not classified as threatened.

6.) The query string should now be pasted at the bottom of the form. It will be longer because it uses the full layer and field names, whereas the query builder and mapping application contain more user-friendly aliases. If satisfied with the query you have composed, click the 'execute' button to run it. If you'd like to try building a different query instead of using the current one, click the 'clear' button to erase the query, and start again.

7.) Once you click the 'execute' button, the active layer will be queried with your criteria. This may take several seconds to run. When complete, the map loading graphic will stop and a table of results will be returned below. Each record in the table corresponds to a feature that met your query criteria. For example, if you chose hatcheries that are anadromous, each record will correspond to one hatchery that raised anadromous fish. These features will also be highlighted in yellow if they are currently in the map view. To zoom the map view to any of the features, click the hyperlinked record number at the left of the table. The map view will then zoom to the extent of that feature, and the feature will be highlighted in red. For features that cover a very large area like the Columbia River, you may not be able to zoom in close enough to see the feature, so the map will zoom to the extent of the feature but it will not be visible.