Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.Start your free trial
There is something wrong with your query. Challenge Task 3 of 3
I'm on the third Task in the Grouping, Joining, and Cleaning Up Challenge.
I believe I've written everything accurately, but my JOIN may not be working correctly.
You're pretty close with that.
In this part:
ON reivews.movie_id = movies.reviews_id
You have a typo on
reviews and the id in the movies table is
The only other issue is the order that you have your tables around the
LEFT OUTER JOIN
reviews LEFT OUTER JOIN movies
With a left join, the table you place on the left side will have all of its rows included but the table on the right will not necessarily have all of its rows included. With it set like this we will get all of the movies that have a review but we will be missing any movies from the movies table that never got a review.
In this case, we need to make sure we've included all the movies from the movies table whether they have a review or not.
I'm sorry I thought it attached my code
SELECT movies.title, IFNULL(AVG(score),0) AS "average" FROM reviews LEFT OUTER JOIN movies ON reivews.movie_id = movies.reviews_id GROUP BY movie_id HAVING average<2;