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 '' at line 12: SELECT count(*) AS count FROM news_tag LEFT JOIN news ON new_id = ntg_new_id WHERE new_active = 1 AND ntg_active = 1 AND ntg_tag_id =