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
Cant write the correct query. Need help
It keeps giving error "Was expecting 4 entries in the products table. There's only 3.
I assume you're referring to task 1 of the challenge? Here's one option:
INSERT INTO products (name, description, price) VALUES ('coffee', 'dark roast', 10);
After naming the table 'products', I listed the column names that I wished to add values for, then the values themselves.. It says that they database is set to auto increment, so you don't need to supply the ID number. The challenge is looking for 4 new values (id, name, description, price). The following code doesn't work:
INSERT INTO products VALUES ('coffee', 'dark roast', 10);
The previous code is trying to add 'coffee' to the ID column of the table. The ID column is set to integer, meaning it can only accept numbers, not text. Since the database is set to auto-increment, I specified which columns I wanted to add values for and the ID updated automatically.
Mine is not working either. Can anyone help? I have:
INSERT INTO products (id, name, description, price) VALUES ("2", "Raven", "shirt", "$20");
I am also getting the same error: "Was expecting 4 entries in the products table. There's only 3."
Oh, that worked. Thank you!