In context of a web application, Is it suitable to do some JOIN operation in Java, on the data retrieved from the database(from first query), and use that \"JOIN\"ed
Are you asking how to do a set intersection in Java? Given your definition of the data--two datasets, entirely integers--here is my suggestion:
Set a = new HashSet(the list of elements from the first dataset) Set b = new HashSet(the list of elements fro the second dataset)
Set joined = a.retainAll(b); // this is how to do set intersections with java.util.Set