mysql - SELECT n row FROM table1 PER table2 -
have 2 table: cats(category) , post.
want select n post per each category.
i have tried this:
select * cat right join (select * post post.catid=cat.id limit 3 ) ...
the problem mysql not recognize cat.id inside sub query.
regards
select a.id, a.category, b.description category inner join post b on a.id = b.cat_id ( select count(*) post c b.cat_id = c.cat_id , b.id <= c.id ) <= 2
Comments
Post a Comment