SELECT a.id, count(*) FROM tb_collect_new a JOIN tb_collect_new_middle b ON a.id = b.new_id GROUP BY a.id