Say I have a table friends
user_1 | user_2
Then, say I want to see what these friends have been up to, so I check the posts table and updates table
post_id | post_title | post_message | user_id | timestamp
update_id | title | userid | timestamp
I want to achieve logic like the following : Get list of friends, go through this list of generated friends to see if they have added anything, sorted by the most recent activities first (timestamp).
Select user_1 from friends where user_2 = '$my_userid'
union
Select user_2 from friends where user_1 = '$my_userid'
//now loop through each of these friends and check the update/post tables to see if they have added anything recently
Can I do this all through 1 MySQL query, or do I have to break it up and use PHP?