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! While you're at it, check out some resources Treehouse students have shared here.

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

Development Tools Database Foundations SQL Calculating, Aggregating and Other Functions Grouping, Joining and Cleaning Up

Outer Join not working! I put the following to run my query and I'm confused as to why it's not working.

Here is my code:

SELECT title, IFNULL(AVG(score)0) AS average FROM reviews RIGHT OUTER JOIN movies ON reviews.id = movies.id GROUP by movie_id HAVING average < 2;

Many thanks!

3 Answers

Matt F.
Matt F.
9,518 Points

Are you using MySQL? Try "RIGHT JOIN" instead of "RIGHT OUTER JOIN"

I am! I just did the change you suggests and it's still not working. Any other ideas? Thanks for your help!

Anuj Nagpal
PLUS
Anuj Nagpal
Courses Plus Student 3,748 Points

SELECT title, IFNULL(AVG(score)0) AS average FROM reviews RIGHT OUTER JOIN movies ON reviews.id = movies.id GROUP by movie_id HAVING average < 2;

cause you are using reviews.id it should be reviews.movie_id