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 Modifying Data with SQL Adding Data to a Database Adding Data With SQL

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

confused...

6 Answers

Tim Abbott
Tim Abbott
14,206 Points

Great thanks. Will do next time!

INSERT INTO products (name, description, price) Value ('t-shirt','white',2.99); I don't understand what is wrong with this code

idk if you figured it out but you need to put a 's' after value

Try this: INSERT INTO products(name, description, price) VALUES("banana","The best fruit",3.99);

Try using strings: INSERT INTO products (id, name, description, price) VALUES (NULL, "banana", "The best fruit ever", 1.99);

INSERT INTO products (id, name, description, price) VALUES (NOT NULL, "Value", "Value", 00.00)

Steven Parker
Steven Parker
231,184 Points

The rest of task 1 says, "Add a new product to the products table. Use any valid values you want. All columns are required. The id column is auto incrementing."

Since the ID column is auto incrementing, it can be left out. So you'll want to construct an INSERT statement that names the other 3 columns, and then supply VALUES for each of them. You can make up anything, it won't care as long as you supply all 3.

Give it a shot, and if you still have trouble post your code here for further assistance.

Tim Abbott
Tim Abbott
14,206 Points

Hi Steve,

I don't see what's wrong with this?

INSERT INTO products (id, name, description, price) VALUES (NULL, Jeans, Blue, £70);

The Error Message says: Was expecting 4 entries in the products table. There's only 3. This suggests that the id with a NULL value is required? I've also tried it without the column names, thinking that may come next.

Thanks in advance....again! Tim

Steven Parker
Steven Parker
231,184 Points

Hi, Tim.

In future, please start a fresh new question to give others a chance to respond to it (plus the ability to vote on answers).

But literal string values (like 'Jeans') must be enclosed in quotes, and the "price" value should be just a number (no currency symbol). Give that a shot.