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 trialCaitlin Baker
15,779 PointsAmbiguous Column
No matter what I come up with, I keep getting 'ambiguous' error messages when I submit this code. I have modified the 'Where' clause every which way I can think of, and it's returning 'main.media.media_id' errors.
SELECT * FROM Media
JOIN Genres ON Genres.genre_id = Media_Genres.genre_id
LEFT OUTER JOIN Media ON Media.media_id = Media_Genres.media_id
WHERE Media.media_id=3;
2 Answers
Simon Coates
28,694 PointsCan you post the URL? I think you should join media with Media Genres, then join to Genres. As is, i think you're attempting to join media to genres directly (while subsequently making reference to a junction table), while attempting to join that to media again. So if i had to guess you probably want something like:
SELECT *
FROM Media JOIN Media_Genres ON Media.media_id = Media_Genres.media_id
JOIN Genres ON Media_Genres.genre_id = Genres.genre_id
WHERE Media.media_id=3;
Caitlin Baker
15,779 PointsOh no! I thought for sure this attached to the question but I added the link. Your answer worked perfectly, thank you - I'm still trying to figure out what I did wrong but I'm having a little trouble with the idea of joining databases, so I will have to do some more reading.