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

PHP

SPYRIDON CHRYSSIKOPOULOS
SPYRIDON CHRYSSIKOPOULOS
12,252 Points

i can't understand what I am doing wrong. The results seem ok

the question is: 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.

My answer is: 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;

the results seem ok, but it keeps telling me that i need to join the genres table. the results look like this: media_id title img genre_id format year category media_id genre_id genre_id genre 3 Refactoring: Improving the Design of Existing Code img/media/refactoring.jpg 17 Hardcover 1999 Books 3 51 51 Business 3 Refactoring: Improving the Design of Existing Code img/media/refactoring.jpg 17 Hardcover 1999 Books 3 17 17 Tech

3 Answers

Try this instead, see if it works. Your answer seems okay to me though.

SELECT * FROM media_genres JOIN media ON media_genres.media_id = media.media_id JOIN genres ON media_genres.genre_id = genres.genre_id WHERE media.media_id = 3;
SPYRIDON CHRYSSIKOPOULOS
SPYRIDON CHRYSSIKOPOULOS
12,252 Points

Hey Adam. The result from your query is the same as mine. The error message from treehouse remains

Not really sure then, I don't remember the course so maybe someone else can help.

Anthony Meyer
Anthony Meyer
2,472 Points

Did you ever find an answer for this?