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 trialJane Hazen
5,168 PointsSQL INSERT INTO() VALUES()
Why is this code not working:
-- Insert "Mark Hapka", "Jessica Rothe", "Eric Jungmann" and "Constance Wu" into the actors table.
INSERT INTO actors VALUES (NULL, "Mark Hapka"), (NULL, "Jessica Rothe"), (NULL, "Eric Jungmann"), (NULL, "Constance Wu");
If I add (id, name) after actors it still comes back saying "Query returned no results."
1 Answer
Steven Parker
231,271 PointsGenerally auto-increment ID fields are disregarded.
This is a bit of a guess since you did not refer to the course, but I'm guessing that "ID" is an auto-increment field. So you can disregard it entirely:
INSERT INTO actors (name)
VALUES ("Mark Hapka"), ("Jessica Rothe"), ("Eric Jungmann"), ("Constance Wu");
If that's not it, please provide a link to the course page you are working with to enable a complete analysis.
Aaren Isabel
6,842 PointsAaren Isabel
6,842 PointsThanks, Steven. But why do we need separate parentheses for each name?
Steven Parker
231,271 PointsSteven Parker
231,271 PointsEven though only one column is being filled, the parentheses identify that each entry represents an entire row.