Welcome Guest, Not a member yet? Register   Sign In
SQL help for users and friends
#1

[eluser]bapobap[/eluser]
Hi there,

I was wondering if anyone can help. I have a users table, then a friends table. In the friends table, I record the users ID and the user ID of the persons friend in the friends table, the table looks like this:

Code:
id
user_id
friend_id
created

There are the different types of relationship, mutual friends (both users have added each other to the table), following (the user has friended another but the other hasn't reciprocated) and followers (users who have friended the user but haven't been friended back).

I'm looking for three succinct SQL queries to produce the results (without any PHP code to merge the data), which I believe should be possible, though it's way out of my expertise range, my brain hurts thinking about it. I would only be able to provide one variable for each query, which is the user id of the user in question. Using a JOIN, I can then find the username etc of each user.

If anyone thinks they can help, please do, though if you think you can help but don't have the time to spare I'd be willing to pay for your time.

Thanks anyone!


Messages In This Thread
SQL help for users and friends - by El Forum - 11-29-2008, 02:58 PM
SQL help for users and friends - by El Forum - 11-29-2008, 10:25 PM
SQL help for users and friends - by El Forum - 11-30-2008, 03:01 AM
SQL help for users and friends - by El Forum - 11-30-2008, 03:07 AM
SQL help for users and friends - by El Forum - 11-30-2008, 06:00 AM
SQL help for users and friends - by El Forum - 11-30-2008, 06:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB