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

Luke McGuigan
Luke McGuigan
14,228 Points

Trouble 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

Simon Coates
Simon Coates
28,694 Points

can you add a link to the challenge this is in reference to?

3 Answers

Simon Coates
Simon Coates
28,694 Points
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';
Luke McGuigan
Luke McGuigan
14,228 Points

Thank you for your assistance, that worked wonderfully, I need to reconsider how I write SQL queries.

Luke McGuigan
Luke McGuigan
14,228 Points

It's just an alias to reference the Media table, though it may be redundant here, regardless I received the same result without it.

Does anybody know the answer to task 3 of this same challenge? Really struggling on that one

Simon Coates
Simon Coates
28,694 Points

Given 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"