Chapter 3. Storing Data

This Chapter covers the basics of the SQL and MySQL commands that are used for getting data into a table. It doesn’t cover topics such as programmatically adding data to a table (see Chapter 8, “MySQL APIs”) or updating data already in a table (see Chapter 5, “Manipulating Data”).

Adding Data to a Table

# Generic syntax
INSERT table_name (list, of, columns)
VALUES (list, of, values);

# Add one row to the book table
INSERT book (title, author, cond)
VALUES ('Where the Wild Things Are',
'Maurice Sendak',
'fine');

The INSERT command allows you to add one or more rows to an existing table. The basic syntax of the command is quite simple. Piece-by-piece, the relevant bits of syntax are

  • INSERTDenotes the start of the command. ...

Get MySQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.