Q: Limit results for each 'where in' match So basically I have a comment table, and replies within. With a separate parent_id column for replies. I wanted to query a random number of comments with a limited number of replies for each comment.
What I did is, I parsed the comments first, got all the primary IDs and went for another query like this
SELECT * FROM Comments WHERE parentID IN (ID1, ID2, ..)

Then I programmatically inserted replies to comments. The thing is, I can limit total replies but not limit replies for each comments. Like 5 reply row for each comment id.
About querying the comment table, I think what I'm doing is not so good performance-wise but the few solutions I found in some SO questions was quite overwhelming to me with very little explanation. So I'm trying to understand little by little and this thing came up out of nowhere. Can't find anything helpful.
