To add new record in the database, use the INSERT INTO command. Here is the syntax of INSERT INTO command:
INSERT into table_name (column1, column2….) VALUES (value1, value2…);
Where: table_name is the name of the table where you want to insert new record; column1, column2 etc. are the name of the columns in the table and value1, value2 etc. are the values you want to insert in the table.
Note: The number of columns that you specify in INSERT INTO command should match the number of values you insert; otherwise you will get an error.We will add a new record in our table. Issue the following command:
INSERT INTO employee_record (f_name, l_name, position, age, salary, email) VALUES (“Piolo”, “Pascual”, “Programmer”, 38, 25000, “firstname.lastname@example.org”);
1. The name of our table is employee_record.
2. Values with quotes are string type (f_name, l_name, position, email) while (age, salary) are integer type.
3. We have not inserted a record in id because we have defined it as auto_increment which means that the id field will increase by one every time we are going to insert a new record.
4. Once you have encoded the command correctly, it will display a success message.
Ex. Query OK, 1 row affected (0.00 sec)