UserRelations{UserID, FriendID, RelationStatus}
And there are users with ID’s 1,2,3 etc.
User 1 send request to user 2
User 3 send request to user 1
So in database I have:
1 | 2 | 1
and
3 | 1 | 1
Now I have a little confusion to write query (maybe design is wrong).
I need to get list of all friends based on userID. But user can be in two columns based on that if he requst relation or someone request relation from him.
If I use this query I get all users who request relation from me, but I get and a list of users that I have sent relation requests, but profile datada that I get is mine and not from that user.
select ur.*, p.FirstName, p.LastName
from userRelations ur
join Profiles p on ur.UserId = p.UserId
where ur.FriendId = @UserId or
ur.UserId = @UserId
I think you’re just missing a join to profiles on
FriendId: