dprichard Posted July 31, 2007 Share Posted July 31, 2007 I have a database with a table for folders that can have subfolders. It is setup like this FolderID FolderName SubFolderID If the user puts something in the main folder it is given a SubFolderID of 1. Anything else is given a SubFolderID of whatever folder it goes into. They can put documents into each of these folders and they are saved in a document table. DocumentID DocumentName DocumentFolderID I am trying to figure out how I can have a query for just the main level of documents that shows the number of documents under that category going all the way down into the sub folders. Since the sub folders can potentially go down infinitely, I am having a little trouble figuring out how to do this. Any help would be GREATLY appreciated. Thank you!!!!!!!!!!!!!!!!!!!!!! Quote Link to comment Share on other sites More sharing options...
Wildbug Posted July 31, 2007 Share Posted July 31, 2007 See the article Managing Hierarchical Data in MySQL, paying particular attention to the nested set model and "Finding the Depth of the Nodes." Quote Link to comment Share on other sites More sharing options...
dprichard Posted July 31, 2007 Author Share Posted July 31, 2007 Awesome!!! I am reading through it now, but it looks like what I was looking for. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.