MySQL Query fail: SELECT avg(rating) as rating FROM sne_ratings as c JOIN sne_users as u ON u.id = c.user_id WHERE c.type = 'blog' AND c.type_id = ORDER BY c.date_rated DESC - 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 'ORDER BY c.date_rated DESC' at line 6