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)
 Query to retrieve n linked accounts

Author  Topic 

ewebb02
Starting Member

6 Posts

Posted - 2006-05-23 : 16:32:07
I'm not sure how many of you all might understand what I'm asking, and I'm sure it's a relatively simple query to write, it's just alluded us so far.

I have a table that links a user with a list of other user's he/she knows. Similar to a buddy list/friend's list.

For an example of what I'm looking for:
My User Bob has friends of John, Frank, Alice.

Alice has friends of James, Bret, Logan

Logan has a friends of Amber and Porter

User Bob goes to view Porter's information. I want to be able to show the lineage of how Bob knows Porter.
Bob -> Alice -> Logan -> Porter

The table structure has the user_id (Bob) and then the friend_id (Alice). Each user has n entries for each of their n friends.

Anythoughts on how to approach this scenario?

Thank you in advance. :)

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-05-23 : 21:01:48
this would help http://www.sqlteam.com/item.asp?ItemID=8866


KH

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-05-24 : 03:27:31
Also try
http://www.nigelrivett.net/RetrieveTreeHierarchy.html

Madhivanan

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

- Advertisement -