mysql - Count and group by -


i have 2 tables :

exp_channel_titles t (parent table) exp_category_posts p (many many table links t via column entry_id) 

i need know how many entries per category each author_id has in p using author_id, entry_id fields t t.channel_id = 7.

e.g.

select cat_id, author_id  exp_channel_titles t, exp_category_posts p t.channel_id = 7 , t.entry_id = p.entry_id group p.cat_id group t.author_id 

try this:

select      p.cat_id,      t.author_id,     count(*) cat_entries      exp_channel_titles t     join exp_category_posts p on t.entry_id = p.entry_id     t.channel_id = 7 group     p.cat_id,     t.author_id 

Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -