Answer the question
In order to leave comments, you need to log in
How to get multiple records from another table to the first one?
Hello! I met on some sites a feed of posts, where a few recent comments are displayed right in the feed under each post (conditionally 3).
Of course, comments are stored separately from posts, but you can’t use LEFT JOIN otherwise we will get a mess from a bunch of duplicate posts in the selection.
I thought about the option to get the posts, and then collect the IDs of the received posts and pull out 3 comments for each using UNION. But if there are 40-50 posts on the page. then it turns out 40-50 UNION.
What other ideas could there be?
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question