Hey everyone --
I currently have a table friends:
member_id (int 10),
connect_id (int 10),
active (char 1)
which contains friend relationships. When active is set to 1, the
relationship is confirmed. When it is set to 0, by default, it is not
yet confirmed.
For example:
member_id connect_id active
1 2 1 // 1 and 2 are friends
2 3 1 // 1 and 3 are friends
3 1 0 // 3 and 1 are not yet
friends.
I'm looking for an SQL query that would return a member and his
friends 3 levels deep. For example:
1 <-> 2 <-> 3
What would this query look like? What is the most efficient way to
write it? How would it change if it were 4 levels deep?
Now, to make things more complicated, I also have a table, members,
which basically looks like:
member_id (int 10),
username (varchar 20).
How could I also join the members table onto the query so I can get a
detailed result, such as:
ensnare <-> michael <-> tyra
Thanks much for your help! Have a great day.