For a set of sql-queries, how do you determine which result-set contains a certain row?
- by ManBugra
I have a set of sql - queries:
List<String> queries = ...
queries[0] = "select id from person where ...";
...
queries[8756] = "select id from person where ...";
Each query selects rows from the same table 'person'. The only difference is the where-clause.
Table 'person' looks like this:
id | name | ... many other columns
How can i determine which queries will contain a certain person in their subset?
For example:
List<Integer> matchingQueries = magicMethod(queries, [23,45]);
The list obtained by 'magicMethod' filters all sql queries present in the list 'queries' (defined above) and returns only those that contain either the person with id 23 OR a person with id 45.
Why i need it:
I am dealing with an application that contains products and categories where the categories are sql queries that define which products belong to them (queries stored in a table also).
Now i have a requirement where an admin has to see all categories an item belongs to immediately after the item was created. Btw, over 8.000 categories defined (so far, more to come).
language and db: java && postgreSQL
Thanks,