O'Reilly logo

Sams Teach Yourself MySQL by Chris Newman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The INSERT Statement

The subset of SQL that enables you to insert data and to update and delete existing records in a table is known as the Data Manipulation Language.

The INSERT statement adds a new row of data to a table. At its simplest, INSERT is followed by a table name, the keyword VALUES, and a list of values in parentheses that correspond to each column in the table in turn.

The products table contains four columns—product_code, name, price, and weight—so you can insert a new product using the following statement:

mysql> INSERT INTO products
    -> VALUES ('NEWPROD', 'A new product', 19.99, 3.5);
Query OK, 1 row affected (0.02 sec)

The response from MySQL indicates that a row has been successfully inserted.

INTO

The INTO keyword is actually ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required