This article will discuss how to insert multiple rows in a MySQL table. Let us get started by making the sample data. We will be creating a table named employee_details.

 CREATE TABLE employee_details(
  emp_id int ,
  emp_enroll_no varchar(255) NOT NULL,
  emp_city varchar(255) DEFAULT NULL,
  emp_firstName varchar(255) DEFAULT NULL,
  emp_lastName varchar(255) DEFAULT NULL,
  primary key(emp_id)
);

Action Output:-

image_1

We will now insert multiple rows into the employee_details table but let us first look into the syntax.

Syntax:-

INSERT INTO name_of_your_table (column1, column2, ....) 
VALUES
(value1, value2 , ....), 
(value1, value2 , ....), 
(value1, value2 , ....), 
...
...
...
(value1, value2 , ....);
  • name_of_your_table: is the table for inserting the rows.
  • column1, column2, …. : is the column list of the table.
  • value1, value2 , …. : are the values to be inserted into columns.
  • Different rows are separated by  ‘ , ‘ and the last row is terminated by a ‘ ; ‘

Query to insert multiple rows into the employee_details table

 INSERT INTO employee_details (emp_id, emp_enroll_no, emp_city, emp_firstName, emp_lastName) 
 VALUES(1,"1-N","Michigan","Henry","Smith"),
 (2,"2-N","Santiago","Richa","Johnson"),
 (3,"3-N","Santiago","Veronica","Brown"),
 (4,"4-N","Washington","George","Jones"),
 (5,"5-N","New York","Harsh","Garcia"),
 (6,"6-N","New York","William","Jones"),
 (7,"7-N","Santiago","Rebecca","Miller"),
 (8,"8-N","Santiago","Paul","Davis"),
 (9,"9-N","New York","Pualou","Miller"),
 (10,"6-N","San Francisco","William","Jones");

Action Output:-

image_2

Ten rows got inserted successfully, as shown in image_2.

Let us take a glance at the table employee_details’ data.

SELECT * FROM employee_details;

Output:-

image_3

Multiple rows are now inserted into the employee_details table in a single MySQL query.

READ MORE:

We hope this article helped you with inserting multiple rows in a MySQL table. Good Luck !!!