select id, catname, catdesc, count(p.catid) from categories c, posts p where p.catid = c.catid group by p.catid