I am trying to execute the following query but I get unknown column for rating_score for the WHERE clause. SELECT SUM(ratings.rating_rating) AS rating_score, posts.ID, posts.post_title FROM posts LEFT JOIN ratings ON ratings.rating_postid = posts.ID WHERE rating_score >= 1 GROUP BY posts.ID ORDER BY posts.post_date DESC LIMIT 5 Code (markup):
Use HAVING SELECT SUM(ratings.rating_rating) AS rating_score, posts.ID, posts.post_title FROM posts LEFT JOIN ratings ON ratings.rating_postid = posts.ID GROUP BY posts.ID HAVING rating_score >= 1 ORDER BY posts.post_date DESC LIMIT 5 Code (markup):