davidb52 Posted October 20, 2011 Share Posted October 20, 2011 Hello,first of all sorry for bad english.But I am trying to make a friend of friend system.Like this:usersf table:id friends0 11 02 11 2 just for example some more:0 33 05 00 52 44 2 so 0/2 are friend with 1, 2 isn't friends with 0 but with 1(and 1 is friend with 0).How could I make a query that return true (or count higher than 0) if I want to know if they are friend of friend.LikeSelect friend where id=0Select friend where id=2if results are the same return true, because they both will have a friend 1 as result.If you don't get me look at this: http://stackoverflow.com/questions/1451868/how-create-sql-query-that-validates-friends-of-friends .The problem with the link is that I don't now how to use (the best answer) for my database. Thanks, David Link to comment Share on other sites More sharing options...
justsomeguy Posted October 20, 2011 Share Posted October 20, 2011 SELECT friends FROM usersf WHERE id IN (SELECT friends FROM usersf WHERE id=x) Link to comment Share on other sites More sharing options...
davidb52 Posted October 21, 2011 Author Share Posted October 21, 2011 solution: select count(id) from `usersf` where id = 2 and usersf.friends in (select `friends` from `usersf` where id = 0) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.