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 trialLuke McGuigan
14,228 PointsTrouble with challenge 2 of Multiple Conditionals (Integrating PHP with Databases)
Hello, the following is the SQL query I've used for this task, whilst it's pulling only the title from the media title in regards to the lastname of 'Tolkien', it seems the issue where this isn't being accepted if that duplicates of each item are being produced.
SELECT title FROM Media me JOIN Media_People m, People p ON m.people_id = p.people_id WHERE fullname LIKE '%Tolkien';
I was wondering if anyone could provide assistance on this.
Thanks
Luke McGuigan
14,228 Pointscertainly, here's the link for this particular challenge: https://teamtreehouse.com/library/integrating-php-with-databases/filtering-input-for-queries/multiple-conditionals
3 Answers
Simon Coates
28,694 PointsSELECT m.title FROM Media m
JOIN Media_People mp ON m.media_id = mp.media_id
JOIN People p ON mp.people_id = p.people_id
WHERE p.fullname like '%Tolkien';
Luke McGuigan
14,228 PointsThank you for your assistance, that worked wonderfully, I need to reconsider how I write SQL queries.
Cindy Lea
Courses Plus Student 6,497 PointsIs me in front of the JOIN supposed to be there?
Luke McGuigan
14,228 PointsIt's just an alias to reference the Media table, though it may be redundant here, regardless I received the same result without it.
Justin Thomas
10,461 PointsDoes anybody know the answer to task 3 of this same challenge? Really struggling on that one
Simon Coates
28,694 PointsGiven the URL provided, the third part looks something like:
SELECT m.title FROM Media m
JOIN Media_People mp ON m.media_id = mp.media_id
JOIN People p ON mp.people_id = p.people_id
WHERE p.fullname like '%Tolkien' and m.category = "Books"
Simon Coates
28,694 PointsSimon Coates
28,694 Pointscan you add a link to the challenge this is in reference to?