

Please note here, that the value for each column is mentioned in the same order as that of the column names. The output statement below shows the time at which the statement was executed, the MySQL statement that was executed and the number of rows that were affected. The query and the corresponding results are as follows:Īs depicted in the picture above, the INSERT statement has executed successfully and inserted one row into the employee’s table. We will add the employee number, first and last name, along with that we will also update the email ID, salary and department id that the new employee should belong to. MySQL INSERT Statement Variations #1) MySQL Insert A Single Rowįirst, we will have a look at a scenario where we have specified both the column names and the values to be inserted using the INSERT INTO keyword.įor Example, Here, we will try to insert a new employee. salary – Holds decimal values of salary for each employee.start_date – Holds date values for the joining date of the employee.salary – Holds decimal values of the salary for each employee.deptNum – Holds varchar for the department ID that an employee belongs to.



Again, this also is mandatory and cannot be omitted. Next, will be the column names to be inserted along with their corresponding values.This is mandatory and cannot be omitted too. Next comes the name of the table on which the insert action has to be performed.This is a mandatory keyword and cannot be omitted. The syntax starts with the keyword “INSERT INTO”, thereby informing the MySQL Server about the type of activity to be performed.INTO tablename (column1, column2, column3.) #5) MySQL Insert Into A Table From Another Table.#2) MySQL Inserting Data Only In Specified Column.
