I have to implement a functionality where I have to show answers of question and some comments on that answer, like stackoverflow.
Currently there are 4 comments in each answer but I want to limit the group by to take 2 comments from each answer.LIMIT will work for entire results.
SELECT ans.answer_id,
GROUP_CONCAT(comm.comment_id) AS comment_ids
FROM `questions_answers` AS ans
JOIN `questions_answers_comments` AS comm
ON comm.answer_id = ans.answer_id
GROUP BY ans.answer_id LIMIT 100
answer_id comment_ids
1 1,2,3,4
2 5,6,7,8
3 9,10,11,12
4 16,13,14,15