Inserting Data Into A Database
insert into names set firstName='Jim', lastName='Smith';
Let's see what happened:
mysql> select * from names;
+----+----------+-----------+
| id | lastName | firstName |
+----+----------+-----------+
| 1 | Smith | Jim |
+----+----------+-----------+
1 row in set (0.00 sec)
Let's add another employee:
insert into names set firstName='Bob', lastName='Rocker';
mysql> select * from names;
+----+----------+-----------+
| id | lastName | firstName |
+----+----------+-----------+
| 1 | Smith | Jim |
| 2 | Rocker | Bob |
+----+----------+-----------+
2 rows in set (0.00 sec)
Alright, cool. We have two records in there and we can see that id field auto incremented starting at 1. That would be your employee id.
How does inserting work?
insert into specifies that we want to insert data into a specified table. In this case, the table we specified was names. We then set fields to their respective values. In the first example, we are setting the field firstName to Jim, followed by a comma so MySQL knows that we want to include a the lastName field which is set to Smith.
So, the definition would be:
insert into [table] set [field], [field], [field], ...;