mysql - Join Tables to fetch user activity -


i have 3 tables users, users_followers , user_activity.

users have data user, email, username, password etch

user_followers have following who

and user_activity stores activity of user, ex. "wrote post"

im having hard time figure out how join tables output have activity user i'm following.

so lets adam follows steve , curt. steve make post , few minutes curt uploads image, steve comments.

i fetch db in sorted timestamp.

ex steve commented on picture curt uploaded image steve made post

i have sql fiddle here http://sqlfiddle.com/#!9/59adf/4

help appreciated!

select u1.user_name `user_name being followed`, u2.user_name `follower_name followes`, ua.*  users u1 join users_followers uf on uf.user_id=u1.user_id join users u2 on u2.user_id = uf.follower_id join user_activity ua on ua.user_id = u2.user_id u1.user_name='demo' order ua.activity_timestamp 

Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - Bypass Geo Redirect for specific directories -

php - .htaccess mod_rewrite for dynamic url which has domain names -