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

Development Tools Database Foundations Introduction to Data, Databases and SQL Inserting Data

Maria De Bruyn
Maria De Bruyn
4,635 Points

How to insert data into database using mySQL

Can anyone tell me what I am doing wrong? Am I making the answer too complicated?

Iain Diamond
Iain Diamond
29,379 Points

Hi Maria,

Could you post your working, please?

iain

Depends on how much data you want to add in. If you want to add a single row to a table in MySQL, you can use the insert syntax.

e.g. insert into TABLE_NAME (COLUMN_NAME_1, COLUMN_NAME_2) values (VALUE_FOR_COLUMN_1, VALUE_FOR_COLUMN_2);

3 Answers

Iain Diamond
Iain Diamond
29,379 Points

Assuming you have the table schema defined correctly for title (e.g. varchar(60)) and year (e.g. int(4)) your SQL statement looks perfectly okay.

iain

Maria De Bruyn
Maria De Bruyn
4,635 Points

INSERT INTO movies (title, year) VALUES ("Back to the Future", 1985);

Maria De Bruyn
Maria De Bruyn
4,635 Points

It looks like the problem was with treehouse. Thanks for your help!