• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to use ONE query to find out tree structure?

New Here ,
Apr 04, 2007 Apr 04, 2007

Copy link to clipboard

Copied

ID------------upperID----------Name------------------------isFolder
1------------ 0---------- Folder 1------------------------------------1
2------------ 1------------ Folder 1- Sub Folder--------------------1
3------------ 2------------ Folder1-Item1-A--------------------------0
4------------ 1------------ Folder 1- Sub Item-----------------------0


Hi all, if I have a table like above to demonstrate the folders and item relationship. This structure allows the user to create unlimited folders and items.

Now I would like to use one query to find out the tree structure of this table, how could I do the query.

Any help on this will be highly appreciated!

Thanks,


ez
TOPICS
Advanced techniques

Views

266

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 04, 2007 Apr 04, 2007

Copy link to clipboard

Copied

I had to do something similar. I used Nested sets with my sql. Here's a good example/tutorial:
http://www.codeproject.com/database/nestedsets.asp

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 04, 2007 Apr 04, 2007

Copy link to clipboard

Copied

LATEST

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation