November 3, 2008 at 11:44 pm
I'm really stuck on this one.
I'm basically building a social networking site for a bit of fun and to push my SQL knowledge and I'm completely stumped at making the connections work.
I've basically got a table which defines a connection which contains an ID and two GUIDs - UserID_Requesting and UserID_Recieving.
I need a way of getting connections for a given UserID recursively, with the information on how a person is connected to another. So for example, if 'bob' was connected to 'jon' and 'jon' was connected to 'sam' and 'sam' was connected to 'eve' then I'd want to pass 'bob' to the proc and receive something like...
ID OF CONNECTION, IDS OF CONNECTION OF CONNECTION IN CONCAT STRING
1 jon, null
2 sam, jon
3 eve, sam|jon
I'd also like to limit that search to 3 levels so it doesn't carry on.
Any advice?
November 4, 2008 at 4:51 am
Have a look at this article: http://msdn.microsoft.com/en-us/library/aa172799.aspx
It's about expanding hierarchies. Your implementation is going to be slightly different because each person is connected to (and therefore a child of) many different people, as a result of which you have a linking table as you described. The principle however should be the same.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply