View Single Post
  #1 (permalink)  
Old June 11th, 2008, 03:28 PM
Itech Itech is offline
Registered User
 
Join Date: Nov 2007
Location: Chicago, IL, USA.
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Recursive Query for Formatted Output

Hello All,

if this has already been addressed please forward me the forum post.
----------
Scenario:
Database Schema
ID ParentID Name
1 0 Root1
2 0 Root2
3 1 Root1_Child1
4 1 Root1_Child2
5 2 Root2_Child1
6 3 Root1_Child1_SubChild1
7 3 Root1_Child1_SubChild2

A select All would output as follows

ID ParentID FormattedPath
1 0 0/Root1
2 0 0/Root2
3 1 0/Root1/Root1_Child1
4 1 0/Root1/Root1_Child2
5 2 0/Root2/Root2_Child1
6 3 0/Root1/Root1_Child1/Root1_Child1_SubChild1
7 3 0/Root1/Root1_Child1/Root1_Child1_SubChild2

i used strings for the Formatted path just so you can see a better visual, i will end up using the ID. for example instead of the formatted output of '0/Root2/Root2_Child1' i will need '0/2/5'

thank you in advance for the help