-
Hi guys,
Can ne1 pls tell me how to go about a table having data in a tree structure.
eg:
i have
id parent name
1 0 a1
2 0 a2
3 1 a3
4 3 a4
5 2 a5
I need all the children of id 1 and all its sub and sub sub children
eg when i query for id 1 .i shoudl get
id parent name
1 0 a1
3 1 a3
4 3 a4
Thanx in advance for help
sam
-
Well, only a well written stored procedure can take care of your requirement, I guess....
Coz, the kind of info you are storing ( tree structure in cyclic relations ), a recursive search is to be performed, the number of which is limited, if it is to be performed using subqueries or the likes.
On the other hand, a SP will certainly be able to churn you out the results....
-
gee got it!!!!
select id,parent,name from table
connect by id = parent start with id=1
a beautiful funda!!!!
more of this here
http://www.arsdigita.com/books/sql/trees.html
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|