Let’s say I have two tables, news and comments.
news ( id, subject, body, posted ) comments ( id, parent, // points to news.id message, name, posted )
I would like to create one query that grabs the latest x # of news item along with the name and posted date for the latest comment for each news post.
Speed matters in terms of selecting ALL the comments in a subquery is not an option.
I just realized the query does not return results if there are no comments attached to the news table, here’s the fix as well as an added column for the total # of posts: