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.
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!