TABLE
id       title        category
1        hello1          1
2        hello2          2
3        hello3          1
Query
select  *
from    videos
where   category in
        (
        select  category
        from    videos
        group by 
               category
        having 
               count(*) < 3
ORDER BY RAND()
        )
my goal is to get 2 titles from each category in a random order also I want to fetch records in this manner
category1
title1
title2
category2
title1
title2
 
     
    