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
 Transact-SQL (2000)
 best way to select this data

Author  Topic 

cakewalkr7
Starting Member

11 Posts

Posted - 2005-09-13 : 16:25:40
I've got a category table with a categoryid field and a parentcategoryid field. The parentcategoryid field is just the categoryid of another row. So, I'm looking to create a navigation bar at the top of a page like so...

Home>Store>Wildlife>Fish

... Wildlife would have a categoryid of say 5 and Fish has it's own categoryid of 12, but a parentcategory of 5. I know that through a couple of queries I can backtrack and get all the ids and create my navigation, but I didn't know if there's a more efficient way in sql to get these ids in a certain order? Anyone have any ideas? Thanks.

nathans
Aged Yak Warrior

938 Posts

Posted - 2005-09-13 : 16:54:34
Hi there. Welcome to the forums. This topic has been well documented here at sqlteam.

Check out these links and please dont hesitate to repost here if you run into any trouble:

http://www.sqlteam.com/item.asp?ItemID=8866

http://www.seventhnight.com/treestructs.asp




Nathan Skerl
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-14 : 00:52:20
Refer this also
http://www.nigelrivett.net/RetrieveTreeHierarchy.html

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cakewalkr7
Starting Member

11 Posts

Posted - 2005-09-14 : 08:17:42
Thanks everyone. That's exactly what I was looking for. And, it's nice to receive a welcome rather than a flame due to bringing up a past discussion topic. Much appreciated!
Go to Top of Page
   

- Advertisement -