Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 recursive select

Author  Topic 

ts_abbott@hotmail.com
Starting Member

36 Posts

Posted - 2004-11-08 : 10:08:26
hi,

i'm trying to select all items from a table starting with parentid x but i'm not sure how to go about it.

This is my table structure:

[i_Page]

PageId | ParentPageId | Name
1 | 0 | Home
2 | 1 | Home Sub Item
3 | 1 | 2nd Home Sub Item
4 | 2 | A subitem which appears under PageId 2


Is it possible to select * from i_Page WHERE PageParentId=1 and all child items' underneath?


cheers

tim

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-11-08 : 10:09:46
If you build a paths table then: Yes, you can select all of the child items

take a look at http://www.seventhnight.com/treestructs.asp

Corey
Go to Top of Page

ts_abbott@hotmail.com
Starting Member

36 Posts

Posted - 2004-11-08 : 14:09:00
thanks, i'll have a look at your website.
Go to Top of Page
   

- Advertisement -