Selecting Features by Attributes in Arcgis - Using The Query Builder
Selecting Features by Attributes in Arcgis - Using The Query Builder
Selecting Features by Attributes in Arcgis - Using The Query Builder
com
Bend, OR 97702
Ph: 541-389-6225
Fax: 541-389-6263
Crating the query expression, or how to tell ArcGIS what you want. In the example
here we will query on a specific type of water meter.
Double-click on the field on which you want to query.
Click once on Get Unique
Values. This will create a list of
all the unique values in that field,
which could take a few seconds
for large databases. Typing part of
the word in the Go To: box will
jump to that part of the values list.
You should always use Get
Unique Values to show the values,
because if the value doesnt show
up in this list, it isnt in the
database and you wont be able to
query on it. The only time you
should not use Get Unique Values
is when there area lot of numbers,
like elevation values of
population.
Single-click on the operator =,
<>, Like, etc (Theres more on
operators on the next page.)
Then double-click on the value
you want from the list of values.
As you click different parts of the
dialog box to create the query,
make sure you see the expression being built in the expression box at the bottom of the
dialog box. It is very easy to move quickly and not quite get in that double-click or singleclick correctly.
Then click Verify to check that the query is working and then click OK, or Apply to run the
query. Verify checks the syntax of the query, but remember that even if the query is written
with the correct syntax, it may not be valid query in that it might not give you the
information you really want.
Using the Database Operators these specify the relationships between Fields
and Values in queries and provide a lot of power in queries.
= Equals
Like Similar to Equal but used for characters or string data
and allows for wildcards and more variations.
> Greater than
< Less than these can be also used
with string data and will then use alphabetical order. Example:
NAME>M% will give you all the words values starting
with M through Z.
<> Not equal to
>= Greater than or equal to
And Both expressions are true; Example: [acres]>= 10 And [property] = Undeveloped
And is exclusive and limits the number of features selected.
Or At least one expression is true;.Example: [acres]>= 10 Or [property] = Undeveloped
Or is inclusive and increases the number of features selected. If you need to select
2 or more values from the same field, you need to use Or.
Example: "PipeClass" = 'C9' OR "PipeClass" = 'C16'
Not excludes values - usually used with And
Example: STRM_CLASS" <= 3 AND NOT "STRM_CLASS" = 0 this would give you
stream classes 1,2 ND 3, and not stream class 0. You could also get the same results by
using: STRM_CLASS" = 1 OR STRM_CLASS" = 2 OR STRM_CLASS" = 3
Is Used with databases that use the NULL keyword as a value
for empty records. Example: Is Null, Is Not Null
If you are working with
tables that dont use
NULL, you can use the
example here to query for
empty records.
() expressions within parentheses
are evaluated first.
Mathematical operators such as +,
-, *, / can also be used in queries
Wildcards such as _ or ? (spaceholder) and % or * (all) can also
be used to further refine selections.
Wildcards are used to select subsets of a text string. The two wildcards are the space holder,
which is either an underscore _ or a ? and the
everything which is either the % or the *
depending on the type of table being queried. The
wildcards are usually used with Like as the
operator. Heres a few examples of how these
would be used, showing the ? and the * as the
wildcard characters.
In this example I want to select all the water meters
in the 100 block of East Black Crater Avenue.
Double-click on Address, click on Get Unique
Values to see all the addresses, and then double
click on any address in the 100 block such as 133 E
BLACK CRATER AVE. Then just delete the 33
and replace that with the * wildcard. The result is
all the meters in that block where the address starts
with 1 are selected. In this case this works because there is no 1000 block, but there is a way to
select only from the 100 block even if there was a 100 block and a 1000 block.