Description
The 'where' clause is not a command, but a common argument to many of the tools that process vector data. It is an important aspect of GME that will help you to be more efficient, and is therefore worth learning about. It allows you to specify a query (an SQL query) that defines a subset of records to process. This means that you do not need to split datasets apart when you only want to process a subset of the data. This makes for much more efficient data management and analysis.
The expression is written using SQL-style syntax. It involves combining field names, operators, values, and logical operators. The convention is to write the field names in uppercase as they appear in the attribute table. Although the entire clause is enclosed in a single pair of quotes, do not put quotes around field names.
The equality operators are:
- = equal to
- < less than
- > greater than
- <> not equal to
- >= greater than or equal to
- <= less than or equal to
- Like (matches portions of a string value)
The values are typically either numbers or strings (string MUST be enclosed in single quote marks). You can also use arithmetic expressions (+, -, *, /). Refer to the ESRI help documentation for more details.
The logical operators are: AND, OR. Parentheses ( ) can be used to group expressions.
It is highly recommended that you experiment with the addcodedfield command when you are learning about the where clause. This command allows you to add a new field and code it with values in a number of ways, therefore providing an easy way of checking whether the where clause is selecting the subset of records you think it should be selecting.
Syntax
where="..."
| ... | is an SQL-style of expression based on the fields in the attribute table |
Example
where=”COUNTY='WOOD' AND YEAR=2009”
where=”(ANIMALID=1010 OR ANIMALID=1011 OR ANIMALID=1012) AND MONTH=12”
where="FID < 10"