Jump to content

friend system table


Jaynesh

Recommended Posts

Ok so if I had one entry how would I adjust my query to affect it both ways.

 

Currently my query pulls a list of all the users friends. This is assuming that there is a double entry.

 

If I have a single entry for e.g

 

user_id  friend id

1            2

 

It treats 2 as a friend of 1 but does not treat 1 as a friend of 2.

 

"SELECT * FROM Users, Friends WHERE user_id = $user and Friends.friend_id = Users.id"

Link to comment
https://forums.phpfreaks.com/topic/241486-friend-system-table/#findComment-1240474
Share on other sites

SELECT * FROM Users, Friends WHERE (Friends.user_id = $user AND Users.id = Friends.friend_id) OR (Friends.friend_id = $user AND Users.id = Friend.user_id)

 

You should probably create a load of test data and benchmark both approaches.  Also make sure you explain extended on the queries.

 

 

Link to comment
https://forums.phpfreaks.com/topic/241486-friend-system-table/#findComment-1240479
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.