SQL INSERT INTO statement
The simplest way to insert data into tables is by using the SQL INSERT INTO statement. This statement requires that you specify the table name and the values to be inserted into the new row. The syntax is:
INSERT INTO table_name (column_name1, column_name2, column_name3…) VALUES (‘value1’, ‘value2’, ‘value3’…)
We will use the Employees table to illustrate the SQL INSERT INTO statement:
+----+------------+-------------------+-----------+-------+-------+
| id | name | address | city | state | zip |
+----+------------+-------------------+-----------+-------+-------+
| 1 | Bill Smith | 123 Main Street | Hope | CA | 98765 |
| 2 | Mary Smith | 123 Dorian Street | Harmony | AZ | 98765 |
| 3 | Bob Smith | 123 Laugh Street | Hope | CA | 98765 |
| 4 | Chang Chao | 123 Dorian Streat | Hong Kong | CN | 98765 |
| 5 | John Smith | 123 Winges road | Toronto | CA | 98765 |
+----+------------+-------------------+-----------+-------+-------+
Following statements will create a new record in the Employees table:
INSERT INTO employee (id, name, address, city, state, zip) VALUES (‘6’, ‘John Doe’, ‘1234 North road’, ‘Toronto’, ‘CA’, ‘98765’);
This will produce the following result:
+----+------------+-------------------+-----------+-------+-------+
| id | name | address | city | state | zip |
+----+------------+-------------------+-----------+-------+-------+
| 1 | Bill Smith | 123 Main Street | Hope | CA | 98765 |
| 2 | Mary Smith | 123 Dorian Street | Harmony | AZ | 98765 |
| 3 | Bob Smith | 123 Laugh Street | Hope | CA | 98765 |
| 4 | Chang Chao | 123 Dorian Streat | Hong Kong | CN | 98765 |
| 5 | John Smith | 123 Winges road | Toronto | CA | 98765 |
| 6 | John Doe | 1234 North road | Toronto | CA | 98765 |
+----+------------+-------------------+-----------+-------+-------+