Top.Mail.Ru
webdev, posts by tag: sql - LiveJournal — LiveJournal
? ?
 

webdev, posts by tag: sql - LiveJournal

About  

SQL: looping query? Aug. 17th, 2010 @ 05:36 pm
Imagevalera
Image
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"
Tags:
Top of Page Powered by LiveJournal.com
Image