select c.classid, c.classname, count(b.id) from (select * from class where status=1 ) c left join (select * from blog where status=1) b on c.classid = b.classid