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 trialGeorge Michael
1,783 PointsSyntax error near SELECT [Exercise]
so i'm following this exercise and i have problem it says syntax error near SELECT but i don't understand why i know there is probably a problem near JOIN but i'm a bit lost ^^
Simon Coates
28,694 Pointsi'm struggling with this stuff myself, but i think you list the all fields you want from the various tables (here it wants all hence the asterisk), then after the FROM you list your tables separated by the JOINs. A JOIN specifies the type of join and what the join is ON.
It may also give you trouble with ambiguous fields. When a field name appears on different tables, you may need to specify which table the field name is in reference to (media_id appears on two tables).
2 Answers
Simon Coates
28,694 Pointsit seems to accept
SELECT * FROM Media JOIN Media_Genres ON Media.media_id = Media_Genres.media_id
JOIN Genres ON Media_Genres.genre_id = Genres.genre_id
WHERE media.media_id=3
George Michael
1,783 PointsThanks a lot :) it's a bit difficult to imagine doing this stuff all by myself tough ^^
George Michael
1,783 PointsGeorge Michael
1,783 Pointshere is my code
SELECT media_id, title, category, img, format, year, category, genre FROM Media SELECT genre_id, genres FROM Genres JOIN Genres AND Media on Media.genre_id = Genre.genre_id WHERE media_id=3;