UserProfile is a table which contains all the details of particular user.
Friends is a table which conatins who have sent a friend request and accepted friends.
In friends table status =1 means it is friend request is pending and if status = 2 means friends request is accepted.
I am writing two queries which returns the friends of both users (current user and another user)
Using INTERSECT keyword it will return who are the mutual friends between 2 users.
select up.UserId, up.UserName,up.PhotoPath from UserProfile up where up.UserId in
(select FriendID from Friends f where f.Status=2 and f.UserID=29
union select f1.UserID from Friends f1 where f1.Status=2 and f1.FriendID=29)
INTERSECT
select up.UserId, up.UserName,up.PhotoPath from UserProfile up where up.UserId in
(select FriendID from Friends f where f.Status=2 and f.UserID=28
union select f1.UserID from Friends f1 where f1.Status=2 and f1.FriendID=28)