DrSmartman
08-04-2003, 05:27 PM
Hello all,
Great forum....first post. Anyway, I'm having some trouble finding a way to represent a tree hierarchy in MySQL. The table design is quite simple, but I am stuck on how to generate a query that can list the whole tree structure. Doing this backwards is quite simple.....can't get this one. What am I overlooking?
I read about a CONNECT BY PRIOR (I think that's what it is called) function in Oracle, but it does not appear MySQL has anything like it.
Sample....
EMPOYEE TABLE
-EMP_ID
-EMP_NAME
-MGR_ID
-CEO
-VP ENGINEERING
-DIR of SOFTWARE DEVELOPMENT
-DEVELOPMENT MGR
-DEVELOPER 1
-DEVELOPER 2
-QA MGR
-QA 1
-QA 2
I think this illustrates the point. If I have a child
entity, I have no problem going backwards, but I am
stuck on how to write a query to list the whole
relationship....? i want to be able to output.....
/CEO
/CEO/VP ENGINEERING
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/DEVELOPMENT MGR
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/DEVELOPMENT MGR/DEVELOPER 1
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/DEVELOPMENT MGR/DEVELOPER 2
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/QA MGR
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/QA MGR/QA 1
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/QA MGR/QA 2
this may seem confusing so let me know.......any help is greatly appreciated.....
THANKS!!!! 8)
Great forum....first post. Anyway, I'm having some trouble finding a way to represent a tree hierarchy in MySQL. The table design is quite simple, but I am stuck on how to generate a query that can list the whole tree structure. Doing this backwards is quite simple.....can't get this one. What am I overlooking?
I read about a CONNECT BY PRIOR (I think that's what it is called) function in Oracle, but it does not appear MySQL has anything like it.
Sample....
EMPOYEE TABLE
-EMP_ID
-EMP_NAME
-MGR_ID
-CEO
-VP ENGINEERING
-DIR of SOFTWARE DEVELOPMENT
-DEVELOPMENT MGR
-DEVELOPER 1
-DEVELOPER 2
-QA MGR
-QA 1
-QA 2
I think this illustrates the point. If I have a child
entity, I have no problem going backwards, but I am
stuck on how to write a query to list the whole
relationship....? i want to be able to output.....
/CEO
/CEO/VP ENGINEERING
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/DEVELOPMENT MGR
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/DEVELOPMENT MGR/DEVELOPER 1
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/DEVELOPMENT MGR/DEVELOPER 2
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/QA MGR
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/QA MGR/QA 1
/CEO/VP ENGINEERING/DIR of SOFTWARE
DEVELOPMENT/QA MGR/QA 2
this may seem confusing so let me know.......any help is greatly appreciated.....
THANKS!!!! 8)