Query a result set from another query


Is it possible to query a result set from another query?


  1. List all employees by organization with ID #1 > returns 10 employees.
  2. From those 10 employees > List all employees working at department with ID #1 > returns 5 employees.
  3. From those 5 employees > List all employees at section with ID #1 > returns 3 employees.

This might sound ridiculous given my example but let’s assume that the result sets from step #1, #2 and #3 is fetched using a complex queries with nested ANDs and ORs then it’s quite complicated to build something which can calculates a filter which covers everything and being sure no data is leaking between the steps.

Using SQL it would be something like (not working but you get the idea :slight_smile:)

select * from  
   (select * from 
       (select * from employees where organization = 10) 
    where department = 1) 
where section = 1


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.