The INSERT INTO statement is used to add rows to a table. The syntax:

INSERT INTO table (column1, column2, etc.)
VALUES ('value1', 'value2', 'etc.')

This will add a new row at the end of the table. Columns where the PRIMARY KEY is AUTO_INCREMENTED need not be specified. In fact, in mySQL it is often better to leave the ID for each row to be AUTO_INCREMENTED. Other columns not listed will receive no data. To add a row to our fict_chars table we might use the following:

INSERT INTO fict_chars (name, book, author)
VALUES ('Pierre', 'War and Peace', 'Tolstoy')

It should be noted that the actual columns do not need to be specified (on line one above) if the VALUES input are in the exact order they are listed in the table. Nevertheless, for clarity's sake, it may be best to include the columns.

< HAVING SQL | LIKE Operator SQL >

Interesting Pages