homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / Databases
Forum Library, Charter, Moderator: open

Databases Forum

Ordering a table where the entries are nested within each other

5+ Year Member

Msg#: 3939664 posted 6:17 pm on Jun 24, 2009 (gmt 0)

i have one table that consists of the following fields

id, parent_id, depth, priority, name

the parent_id relates to the id of another item in the table which it falls below. depth is how many folders deep the entry is. sort of like a file structure where every folder is a row in the table.

well, i want to write one query to pull all the entries and display them like a folder tree. its easy enough to pull the parents priority order by that then order by its own priority. but since the number of levels deep this can span is infinite, it would have to be a recursive subquery...if thats even possible?

at the time of entry for a new row, i could grab info from the parent and its grandparent etc and add it to a new column, but i'm not sure what info to grab or how to use that info. any ideas are appreciated!


Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Databases
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved