You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''241\' group by dpare_category.category_id order by cname' at line 5SELECT dpare_category.category_name as cname,dpare_category.category_id as cid, count(dpare_articles.article_id) as arr FROM dpare_articles right join dpare_category on dpare_category.category_id= dpare_articles.category_id and dpare_articles.status='A' where dpare_category.category_root='241\' group by dpare_category.category_id order by cname