AnsweredAssumed Answered

Performing a Query Based on a the results of a previous query.

Question asked by PW941248 on Apr 1, 2014
Latest reply on Apr 2, 2014 by PW941248
I have a point layer, with a related table. In this case I'm mapping schools in the point layer and each school has many programs which are recorded in the related table. I'd like to query the related table for specific programs, and return the school ID's that have these programs, then I'd like to use the school ID's returned from the query of the related table, to query the point layer and display a graphics layer based on that second query.

Originally I thought maybe a query related records would work, but since it doesn't allow for a traditional "where clause, and since I"m going from the "many" table back to the "one" table, I'm not sure how that would work. Again, I'm a novice at this.

Here are my conceptual steps as to how I would do this. I'd like some input from some more experienced people as to if this is possible/wise, before I spend a lot of time banging my head against the wall.

Step 1: Query related table for desired programs for example a query task based around query where program = biology, not returning geometry(since there is none) and only returning the outfield that corresponds to the school ID in the point layer. This would return a feature set which only has the school IDs with a biology program in it.

Step 2: Use the results of the first query in the "where" clause of a second query, which queries the point layer to return the schools that have biology programs.

Step 3: return graphics for the second query.

If this design is wise, I think my main hangup to use the results of the first query in the "where" clause of the second query.

Any input on this would be great, specifically with regard to how to use the results of the first query in the where clause of the second query. Is there any, or could you provide sample code for this type of procedure.