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

Popular posts from this blog

Capture and play voice with Asterisk ARI -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -

visual studio - Installing Packages through Nuget - "Central Directory corrupt" -