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 trial

Databases

We have an eCommerce database and it has a products table. It has the columns id, name, description and price.

INSERT INTO products (id, name, description, price) VALUES (NULL, "armand fandera", "this is test", "99.90"), (NULL, "armand fandera", "this is test", "99.90"), (NULL, "armand fandera", "this is test", "99.90"), (NULL, "armand fandera", "this is test", "99.90");

Steven Parker
Steven Parker
229,645 Points

Could you provide a link to the course page you are working with, to allow us to analyze the issue?

4 Answers

Steven Parker
Steven Parker
229,645 Points

You're inserting too many products.

Now that I see the challenge, the second sentence of the instructions is "Add a new product to the products table." That would mean one new product. But your original query adds four products.

But just for grins, I tried pasting your entire original query into the challenge — and it passed! It probably should not, and I have no idea why it works for me but did not work for you.

And what I meant by "completely omitting the id values" would look like this (and it also passes):

INSERT INTO products (name, description, price) VALUES ("armand fandera", "this is test", "99.90")

thanks for great help.

Steven Parker
Steven Parker
229,645 Points

Try omitting the NULL values.

Without seeing the challenge I'm guessing here, but I'm assuming the "id" field is an auto-increment field? Try leaving it off completely in the values instead of using "NULL" as a placeholder.

Let me check

`INSERT INTO products (id, name, description, price) VALUES ("NULL", "armand fandera", "this is test", "99.90"), ("NULL", "armand fandera", "this is test", "99.90"), ("NULL", "armand fandera", "this is test", "99.90"), ("NULL", "armand fandera", "this is test", "99.90");

SQL Error: datatype mismatch`

and i have check with this too : `INSERT INTO products (id, name, description, price) VALUES ("", "armand fandera", "this is test", "99.90"), ("", "armand fandera", "this is test", "99.90"), ("", "armand fandera", "this is test", "99.90"), ("", "armand fandera", "this is test", "99.90");

Was expecting 4 entries in the products table. There's only 3. ` Error came.

Robbie Thomas
Robbie Thomas
31,093 Points

My first attempt at the challenge, I used a number for the ID and it told me no. So, by Steven Parker's answer, I omitted the NULL and I passed. This was just for the first challenge here.

On the second and third challenges, the NULL was accepted. Seems like they made a mistake with the first challenge.