List:General Discussion« Previous MessageNext Message »
From:Saqib Ali Date:March 10 2009 9:18pm
Subject:using a subquery/self-join to recursively retrieve a tree
View as plain text  
Hello,

I have following simplistic DB representing a hierarchy:

+------------+----------+------+-----+---------+-------+
| Field      | Type     | Null | Key | Default | Extra |
+------------+----------+------+-----+---------+-------+
| uid        | int(10)  | NO   | PRI | 0       |       |
| name       | char(80) | YES  |     | NULL    |       |
| mail       | char(80) | YES  |     | NULL    |       |
| manageruid | int(10)  | YES  |     | NULL    |       |
+------------+----------+------+-----+---------+-------+

How can I do some recursion to get the UIDs of all the employees
reporting up to a manager, regardless of how deep the tree is. I can
do this usindg LDAP and/or PHP, but not sure how to do it as a mysql
query.

Any thoughts? Thanks

saqib
http://www.capital-punishment.us
Thread
using a subquery/self-join to recursively retrieve a treeSaqib Ali10 Mar
  • Re: using a subquery/self-join to recursively retrieve a treePeter Brawley10 Mar
  • Re: using a subquery/self-join to recursively retrieve a treeClaudio Nanni11 Mar