Error: SELECT count(company_id) FROM company_city_cat a JOIN company b on a.company_id = b.id WHERE city_id = 4983 AND cat_id = AND b.approved > -1 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'AND b.approved > -1' at line 1