[mysql]recursive select?
Posted: Thu May 10, 2007 4:04 am
I have been asked to ensure that for every project we have in our Mantis records, that when the parent project has a new version added, this version is also added to every sub-project. Parent projects can have any number of sub-projects, and those sub-project too can have sub-projects (and etc. into oblivion). I've done this before, but using php and multiple queries, but this time I was wondering if it is possible to recursively select?
Table structure of the relevant table is simple:so as you can see, I would need to loop down collecting the ids.. any suggestions?
Much obliged.
Table structure of the relevant table is simple:
Code: Select all
mysql> desc mantis_project_hierarchy_table;
+-----------+------------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-----------+------------------+------+-----+---------+-------+
| child_id | int(10) unsigned | NO | | | |
| parent_id | int(10) unsigned | NO | | | |
+-----------+------------------+------+-----+---------+-------+
2 rows in set (0.00 sec)Much obliged.