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 trialMohamed Elauzei
2,191 PointsInsert Statement Challenge
Hi there
When I run this code { INSERT INTO products (id, name, description, price) VALUES (1, "jeans", "hdksjfjee nfis", 9.9); }
for the challenge it gives me an error saying that I only entered 3 values when it expects 4 entries, even though I actually did provide 4 entries.
I have no idea why this is happening.
1 Answer
Steven Parker
231,059 PointsThe table already has 3 entries, your code should insert a 4th. So the error message is just saying it did not work.
The clue is where the instructions say "The id column is auto incrementing." An auto-increment column should not be given an explicit value, so the "id" column can be given a "null" value, or it can be omitted entirely.
Mohamed Elauzei
2,191 PointsMohamed Elauzei
2,191 PointsI actually first tried omitting the "id" value because it's auto incrementing and it didn't work. But I now tried inserting a NULL value and it worked. Thanks a lot.
Steven Parker
231,059 PointsSteven Parker
231,059 PointsThis would also work:
INSERT INTO products (name, description, price) VALUES ("jeans", "hdksjfjee nfis", 9.9);
Happy coding!