Not sure I see the need for the first query. If the friends table is asymmetric and looks like
friends {
i_am foreign key references user_info,
my_friend foreign key references user_info
}
And you just SELECT p.message from posts p join friends f on f.my_friend = p.author where f.i_am = $my_id order by p.when_posted LIMIT $max_posts_to_show (this is completely untested)
You could extend this to join with the user table to get the author info that you want to display. If the appropriate columns are key / indexed, this should be much more than sufficiently quick until you get a bazillion messages at which point you want to partition the tables to deal only with recent ones, for some definition of 'recent'
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
It is never necessary to create a VIEW. Sometimes convenient. Your mileage may vary...
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256
The short answer is 'just like with two'. The medium answer is RTFM . And the long answer is 'it depends on exactly what you need to have happen' (in other words: RTFM, and probably, experiment)
P.S. Once a thread is marked 'solved' it is generally considered bad form to add to it. I've done so because you are the OP here, but next time you might want to think before you hit the 'solved' button.
griswolf
Veteran Poster
1,165 posts since Apr 2010
Reputation Points: 344
Solved Threads: 256