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 trialTrần Phúc
2,264 PointsUSE JOIN IN DATABASES
I dont know what wrong? PLEASE HELP ME THANKS
[CHALLENGE] We will be writing ONLY the SQL query for this challenge. The library database contains a Media table with the columns media_id, title, img, format, year and category. It also contains a Genres table with the columns genre_id and genre. To join these tables, there is a Media_Genres table that contains the column media_id and genre_id Add to the following SELECT statement to JOIN the Media table and the Genres table using the joining table Media_Genres. SELECT * FROM Media WHERE media_id=3; NOTE: You will need to add the table to the WHERE clause so that the media_id column is not ambiguous.
> SELECT*FROM Media,Genres JOIN Media_Genres ON Media_Genres.genre_id=Media_Genres.media_id WHERE media_id=3;
SQL Error: ambiguous column name: media_id
1 Answer
Steven Parker
231,261 PointsYour immediate issue comes from the WHERE clause:
WHERE media_id=3;
Since you're joining tables where more than one of them has a "media_id" column, you must be specific now:
WHERE Media.media_id = 3;
But it looks like you may need to work on your JOINing a bit also.
Trần Phúc
2,264 PointsTrần Phúc
2,264 PointsIt dont right with this challenge .May be i dont understand this challenge .Can you explain more about challenge help me?.Thanks Minh Phuc
Steven Parker
231,261 PointsSteven Parker
231,261 PointsHere's some more hints. When you JOIN with this:
ON Media_Genres.genre_id=Media_Genres.media_id
You are matching the genre_id of one table with the media_id of another. You probably want to match only the columns of the same name.
You may also want to expand the first join to be explicit like the second one.
If you're not sure how to do this, you might want to re-watch the video just before the challenge.