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!
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
Robbie Thomas
31,093 PointsInserting Data Code Challenge 2/2
Tried this:
INSERT INTO actors VALUES ("Micheal J. Fox");
And it's telling me to go screw myself. What does the code challenge want? I'm confused...
2 Answers

Robert Bojor
Courses Plus Student 29,439 PointsHi Robert,
When you are trying to insert into a table and not specify the actual columns before the VALUES keyword, the SQL server expects you to supply all the field values, in the same order they were created in the table.
For example, you have the table actors, which normally should have a column called id and another column called name. You can write the insert query in two different ways:
INSERT INTO actors (name) VALUES ('Michael J. Fox');
or
INSERT INTO actors VALUES (NULL, 'Michael J. Fox');
If your first column has autoincrement, it will take the first NULL and assign it the next available number and insert the name on the row.
You can always specify the next number instead of NULL but that will require you to find what that next number is first, and it is actually better to let the SQL server do that for you.

The Hacker
20,260 PointsCould you be more specific?

Robbie Thomas
31,093 PointsIt's under MySQL, gone that far?
Robbie Thomas
31,093 PointsRobbie Thomas
31,093 PointsHeh, the guy on the video didn't mention single quotation marks. Thanks.
Robert Bojor
Courses Plus Student 29,439 PointsRobert Bojor
Courses Plus Student 29,439 PointsI prefer them because I wrap my queries into double quotes, so in order not to escape them all the time, I use the single ones inside the query.