SQL: looping query?
I have a 'managers' table with a MANAGER_ID and EMPLOYEE_ID columns, an entry in the table signifying that the employee with id MANAGER_ID is a manager of the employee with id EMPLOYEE_ID.
The setup is so that If "A" manages "B" and "B" manages "C" and "C" manages "D" then "A" manages "B", "C", and "D". In SQL, how would I write a query that would return a list of all the ids that an employee with a given id manages?
Also, even though this probably would not happen, but how would such a query deal with "A" managing "B" and "B" managing "A"
The setup is so that If "A" manages "B" and "B" manages "C" and "C" manages "D" then "A" manages "B", "C", and "D". In SQL, how would I write a query that would return a list of all the ids that an employee with a given id manages?
Also, even though this probably would not happen, but how would such a query deal with "A" managing "B" and "B" managing "A"
