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

Giovanni P.
Giovanni P.
4,803 Points

I don't understand why query isn't working

Okay, so the task wants me to query all the media titles assosciated with someone witht he last name "Tolkien". When I use this query:

SELECT media_id FROM Media_People WHERE people_id = (SELECT people_id FROM People WHERE fullname LIKE '%Tolkien')

I recieve the the media_id's 7 and 13, so far so good. But when I add on to it like this:

SELECT title FROM Media WHERE media_id = (SELECT media_id FROM Media_People WHERE people_id = (SELECT people_id FROM People WHERE fullname LIKE '%Tolkien'))

I only recieve the title for the media_id 7, but not 13, and I don't understand why. I'm probably missing something small, but any help would be appreciated. Thanks!

1 Answer

Steven Parker
Steven Parker
231,128 Points

You probably meant to write "WHERE media_id IN ..."

Using "IN" would match on the whole list where "=" would just match the first item returned.