我有两张桌子:
exp_channel_titles T (parent table)
exp_category_posts P (many to many table that links to T via column entry_id)
我需要知道每个author_id
个类别中有多少条目使用来自T author_id
的{{1}},entry_id
字段。
e.g。
T.channel_id = 7
答案 0 :(得分:1)
试试这个:
SELECT
p.cat_id,
t.author_id,
count(*) as cat_entries
FROM
exp_channel_titles t
join exp_category_posts p on t.entry_id = p.entry_id
WHERE
t.channel_id = 7
GROUP BY
p.cat_id,
t.author_id