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 'hospitalId ASC LIMIT 20' at line 8
Query: SELECT hospitals.*, companyName,AVG(ratings.rating) hospitalRating FROM c4p_hospitals hospitals JOIN c4p_companies companies USING(companyId) LEFT JOIN `c4p_ratings` ratings USING(hospitalId) WHERE hospitals.status = 1 AND hospitals.companyId = 1 GROUP BY hospitalId ORDER BY ,hospitalId ASC LIMIT 20