I need help applying a limit to a Left Join in a Select query.
I have a table with posts and another one with videos. I want to select a list of posts with some filters applied, and their respective videos, limited to 25 videos per post. Now I get ALL videos for a post, which could be hundreds and which is slow!
My current Sql looks like this:
SELECT `post`.`id` AS `post_id`,
       GROUP_CONCAT(CONCAT(`video`.`id`, ',', `video`.`timestamp`) SEPARATOR ';') AS `videos`,
       COUNT(`video`.`id`) AS `video_count`
  FROM `post`
       LEFT JOIN `video` -- Don't know how to limit these videos to 25 items
       ON `video`.`category_id` = `post`.`category_id`
       AND `video`.`file_size` > 0
       AND `video`.`timestamp_beginning`
           BETWEEN `post`.`timestamp` - INTERVAL 5 MINUTE
           AND `post`.`timestamp` + INTERVAL 5 MINUTE
 WHERE `post`.`author_id` = 2 AND `post`.`status` = 'active'
 GROUP BY `post`.`id`
 ORDER BY `post`.`id` DESC
 LIMIT 100,100;
Thank you!
 
    