php - MySQL query for two way relationship -


for social web application needed create mysql table in following way,

id | user_id | friend_id ------------------------  0 |    5    |   6  1 |    6    |   5 

user 5 , user 6 friends. how can list of friends particular user. point me in right direction please?

select f1.user_id, f2.user_id 'friend'     friends f1 left join friends f2    on f1.user_id = f2.friend_id  

for more information please refer post what's difference between inner join, left join, right join , full join?


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -