I'm having a lot of difficulty trying to figure this out.  I have a table 
with a list of projects that I would like to arrange and view as a tree.
This is my table:

+--------+------------------+------+-----+---------+----------------+
| Field  | Type             | Null | Key | Default | Extra          |
+--------+------------------+------+-----+---------+----------------+
| id     | int(10) unsigned |      | PRI | NULL    | auto_increment |
| name   | varchar(64)      |      | MUL |         |                |
| handle | varchar(18)      |      |     |         |                |
| parent | int(10) unsigned |      |     | 0       |                |
| status | varchar(64)      |      |     |         |                |
| data   | text             | YES  |     | NULL    |                |
+--------+------------------+------+-----+---------+----------------+

This is what I want to get in the end:


 + root project
    |
    + project 1
    |   |
    |   + sub project 1.1
    |   + sub project 1.2
    |        |
    |        + sub project 1.2.1
    |
    + project 2
        |
        + sub project of 2.1
        + sub project of 2.2


What SQL statement(s) would retrieve my records, ordered by project ID, but
grouped recursively into a tree?  Or, is this something not possible through
SQL itself?

Thanks,



Davis


--
Design Office
11912 Washington Blvd.
Los Angeles, California
t. 310 390 8098
f. 310 390 6029

Reply via email to