Complex Query Find

3311
6
Jump to solution
05-11-2012 12:24 AM
LucaAlferi1
New Contributor
Hy
I have used the query sample code.
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {  self.mapView.callout.hidden = YES;  self.findParams.contains = YES;  self.findParams.layerIds = [NSArray arrayWithObjects:@"1",nil];  self.findParams.outSpatialReference = self.mapView.spatialReference;  self.findParams.returnGeometry = TRUE;  self.findParams.searchFields = [NSArray arrayWithObjects:@"fieldName1",@"fieldName2",nil];  self.findParams.searchText = searchBar.text;  [self.findTask executeWithParameters:self.findParams];  [searchBar resignFirstResponder]; }

My question!!!
How can i research a layer that execute a query type as:
"filedName1 And fieldName2"
???
Thanks
0 Kudos
1 Solution

Accepted Solutions
NimeshJarecha
Esri Regular Contributor
Luca,

Your where clause should be,

query.where = [NSString stringWithFormat:@"foglio = '%@' AND particella = '%@',foglioTextField.text,particellaTextField.text];

Hope this helps!

Regards,
Nimesh

View solution in original post

0 Kudos
6 Replies
RickJones
Occasional Contributor II
Use AGSQuery and AGSQueryTask instead, for complex queries.
0 Kudos
LucaAlferi1
New Contributor
Use AGSQuery and AGSQueryTask instead, for complex queries.


my code is
AGSQuery* query = [AGSQuery query];
    query.text = searchBar.text;
    query.outFields = [NSArray arrayWithObjects: @"foglio_partic", nil];
    query.returnGeometry = TRUE;
    query.outSpatialReference = self.mapView.spatialReference;
    [self.queryTask executeWithQuery:query];

in the log file this code is good, but not show in map the result
why??
Please help me
0 Kudos
NimeshJarecha
Esri Regular Contributor
Is your query executes successfully and it fires queryTask:operation:didExecuteWithFeatureSetResult: of AGSQueryTaskDelegate? If yes, it is your responsibility to add result (graphics in feature set) to graphics layer to be shown on map.

Regards,
Nimesh
0 Kudos
LucaAlferi1
New Contributor
Promethia;226466 wrote:
my code is

AGSQuery* query = [AGSQuery query];
    query.where = ??????????
    query.outFields = [NSArray arrayWithObjects: @"foglio", @"particella",nil];
    query.returnGeometry = TRUE;
    query.outSpatialReference = self.mapView.spatialReference;
    [self.queryTask executeWithQuery:query];



In my project i use two UIText Field. One i use for write the number of "foglio" and one for write number of "particella". I want find the "particella" that satisfies the condition "foglio AND particella " with function query.where = ..., but i don't know how to do it.
Please Help me
0 Kudos
RickJones
Occasional Contributor II
self.queryTask = nil;

// i've already setup the other query properties like returnGeometry
self.query.text = @"";
self.query.where = @"STREET = 'MAIN' AND SUFFIX = 'ST'"; // example of where clause
    
  self.queryTask = [AGSQueryTask queryTaskWithURL:[NSURL URLWithString:kCivicURL]];

self.queryTask.delegate = self;
 
//execute find task
self.operation = [self.queryTask executeWithQuery:self.query];
0 Kudos
NimeshJarecha
Esri Regular Contributor
Luca,

Your where clause should be,

query.where = [NSString stringWithFormat:@"foglio = '%@' AND particella = '%@',foglioTextField.text,particellaTextField.text];

Hope this helps!

Regards,
Nimesh
0 Kudos