The Query object
In order for the QueryTask object to execute a query against a layer in a map service you need to define the query in a Query object.
The Query object will specify whether the query will be spatial, attribute, or a combination of the two.
Attribute queries can be defined by either the where or text properties. These properties are used to define a SQL attribute query. We'll look at the difference between Query.where and Query.text in a bit.
Spatial queries require that you set the Query.geometry property to define the input geometry that forms the basis of the spatial query.
Creating a new instance of the Query object is as simple as calling its constructor with no parameters:
var query = new Query();
Setting query properties
At the bare minimum, you need to specify whether the query you want to create is attribute, spatial, or both.
Attribute queries
The Query object provides two properties that can be used in an attribute query: Query.where and Query.text.
In the following code...