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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![George Stathoulias](https://secure.gravatar.com/avatar/63f17eebc4a7f0b27c517bf3266ec52e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
George Stathoulias
Courses Plus Student 4,296 PointsTask 2 of 3
Here's my query: SELECT title FROM Media JOIN People ON Media.media_id = People.people_id LEFT OUTER JOIN Media_People ON Media.media_id = Media_People.media_id AND People.people_id = Media_People.people_id WHERE People.fullname LIKE '%Tolkien';
What is wrong??
2 Answers
![Jennifer Nordell](https://uploads.teamtreehouse.com/production/profile-photos/5432702/micro_jen-square.jpg)
Jennifer Nordell
Treehouse TeacherHi there, George Stathoulias ! First, you need two INNER
joins. So you won't need LEFT OUTER JOIN
. You have some combination here where you're trying to do the media_id = people_id
from different tables. But the media_id
in one table should be equal to the media_id
recorded in the other table. The same thing goes for media_id
. The Media_People table is just a table with two columns. Each column has a list of integers. One column is for the people_id
and the other column is for the media_id
. Assuming the person was "Tom Hanks" and their people_id
was 3, I'm expecting that "Media_People" table to have quite a number of entries where the people_id
is 3 and each movie he's been in is recorded with its media_id
which then looks up the title of the movie in the Media table.
This was my solution:
SELECT title FROM Media
JOIN Media_People ON Media_People.media_id = Media.media_id
JOIN People ON People.people_id = Media_People.people_id
WHERE fullname LIKE '%Tolkien';
Note that the media_id in the joining table matches the media_id in the Media table and the person_id in the joining table matches the person_id in the Person table.
Hope this helps!
![George Stathoulias](https://secure.gravatar.com/avatar/63f17eebc4a7f0b27c517bf3266ec52e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
George Stathoulias
Courses Plus Student 4,296 PointsThank you Jennifer. You made things clear!