I’m trying to fetch mutual friends.
I have a table structured like this:
`friends` (
`inviter` int(11) NOT NULL,
`accepter` int(11) NOT NULL,
`time` datetime NOT NULL,)
ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_turkish_ci;
My load_my_friends(##MY ID##); query is like this:
SELECT p.id , p.name,p.lastname,p.thumb
FROM friends AS f
RIGHT JOIN profiles AS p ON ( f.accepter = p.id OR f.inviter = p.id )
WHERE f.inviter = ##MY ID##
OR f.accepter = ##MY ID##
LIMIT 0 , 5000
Could you tell me how I can fetch the mutual friends data.
Note: I’m not using any social-network script like JCOW,Social Engine etc.
Edit for @2
In the database I have user1,user2,user3,user4,user5..userX
- user1’s friends are: 2,3,6,7,8
- user2’s friends are: 1,3,4,5,7,8
I want a query which can fetch these results:
| id | name |lastname| thumb
1| 3 |raheel|shan | /img01.jpg
2| 7 | arqu |x | /img02.jpg
3| 8 |abcdef|hijklmno| /img06.jpg
A query that’s probably easy to understand is the following: