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

Databases

Javier Pons
Javier Pons
15,010 Points

Dont know how to join tables from another table

This is what i have so far

SELECT * FROM Media JOIN Genres ON Media.media_id = Genres.genre_id WHERE media_id;

this is the challenge im stuck in

https://teamtreehouse.com/library/integrating-php-with-databases/using-relational-tables/joining-tables

please help me . thank you in advance

1 Answer

You need to join 2 tables

SELECT * FROM Media
JOIN Media_Genres
ON Media.media_id = Media_Genres.media_id 
JOIN Genres 
ON Genres.genre_id = Media_Genres.genre_id
WHERE Media_Genres.media_id = Media.media_id