MySQL Forums
Forum List  »  Stored Procedures

Path of entry in hierarchical table
Posted by: Glenn Thomas Hvidsten
Date: May 05, 2012 03:36PM

I have a table with tree fields: ID, ParentID and Name
I'm in need of a function/procedure that can return the path of a certain row.

Say I have the following rows:

ID ParentID Name
1 NULL Root
2 1 Temp
3 1 Folder
4 2 SubItem

If I input ID 4 into the function/procedure I would like it to return "/Root/Temp/SubItem/".

I have been experimenting and googling all night without finding a solution.
How would I go about making such a function or procedure?

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.