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.
Author |
Topic |
vondiplo
Starting Member
8 Posts |
Posted - 2008-12-03 : 13:59:59
|
Hello all,I've got a table of users, and another table of 'friendships'. For two given users, I want to be able to say if how many levels of mutual friends they have.Explanation, assume:Person APerson BPerson CPerson A is friends with B, and person B is friends with C, that means that person A and C are friends of second degree. I want to be able to map my small database to friendship levels. Does anyone have an idea how to do so? |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
|
vondiplo
Starting Member
8 Posts |
Posted - 2008-12-05 : 08:36:21
|
Thank you very much Peso, a nice and elegent solution. I did notice you didn't use an recursion, which was my approach. Simplifies it greatly. How would you solve it with recursion though? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-12-05 : 09:13:12
|
The CTE uses recursion... E 12°55'05.63"N 56°04'39.26" |
|
|
vondiplo
Starting Member
8 Posts |
Posted - 2008-12-05 : 09:24:26
|
Sorry for nudging. You've been of great help. Thank you again. Though,what would be the equivalent of CTE in oracle PLSQL ? |
|
|
|
|
|