0

With PHP & MYSQL, I need a scalable way to show a few comments for each post just like in facebook. For all the posts in my application I need to print the most recent comments beneath the post. The problem is that I dont want to put a SQL query in a loop and have to run 20 SQL queries per page. Is there one SQL query that I can use to get the 2 most recent comments for each post that I get from the posts table.

1 Answers1

0

I believe you can retrieve all the comments using one query and then store them in an array. You can then iterate over the array to organize them.

Ren
  • 1,111
  • 5
  • 15
  • 24
Dvid Silva
  • 1,110
  • 13
  • 25