title: How to do a JOIN on table in a HasMany relationship, if only the latest row on the joined table is searched or?
body: <p>I have a Post and PostComment model. They are in a HasMany relationship, as the picture suggests.
  <a href="https://i.stack.imgur.com/nTJ0M.png" rel="nofollow noreferrer">ER diagram</a></p>
  <p>I need to return all posts, and, the latest comment for each post, paginated.</p>
  <p>The problem is that I need also to do a search on the &quot;post_comments&quot; table. Something like &quot;get all posts from a specific user, ...&quot;. So I decided to use the JOIN.</p>
  <p>My problem is that with JOIN I do not receive only one entry per post, but rather as many post entries, as there are comments in the related table.</p>
  <p>I tried to group the result by &quot;post_id&quot;, but some critics said that this is not good. What would be the &quot;proper approach &quot; for this?</p>