Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.


Ethan Martin
Ethan Martin
Courses Plus Student 1,883 Points

Enter a review for E.T. Use a username and review of your choosing.

The scheme for reviews doesn't have a title column, only a column for the movie ID.

This task is asking me to insert a review into that data base for ET.

Say I didnt have the movie ID? Or I just didnt want to look it up just so I could insert the value appropriately into the reviews data base.

Is there some way to link the two tables and say "Insert a review for ET by inserting the id that the movie is linked to, then insert username, review, and rating?"

Maybe that's asking two much for one line of code. but I feel like there has to be a simpler way to accomplish this.

2 Answers

Here's an explanation from w3schools of INSERT INTO SELECT and an explanation of literals from geeksengine.com

INSERT INTO reviews (movie_id, username, review, rating)
SELECT movie_id, "my username", "my review", my rating
FROM movies
WHERE title = "E.T.";
Ethan Martin
Ethan Martin
Courses Plus Student 1,883 Points

If it wouldn't be too much trouble, could you break down in words what this is doing?