Hi,
I am trying to create a friend system for my users. I have a question but first, here is my setup for the friends (link) table:
ID | Friend1_id | Friend2_id | Accepted
Friend1 is the person making the request and Friend2 is the person who has been requested. This works fine and dandy until I need to show a friends list on any users profile. Mainly because sometimes you would be the person who requested and sometimes you would be the person who received a request.
What i mean is say I wanted to get user X's friends and JOIN it with the user table..
SELECT * FROM FriendTable LEFT JOIN (`users`) ON ( [B][COLOR="Red"]*something here*[/COLOR][/B] ) WHERE (Friend1_ID = 'user_id' AND Accepted = 'y') OR (Friend2_ID = 'user_id' AND Accepted = 'y')
The something here part poses a problem because I don't know which is the users friend and which is well, the user. Sometimes it would pull their own id.
I thought of adding another table instead of the column accepted but I would have to enter a 2 relationships for each set of users.
I'm probably making this more complicated than it is. Any suggestions?
Thank you