Insert multiple data using SQL

Last updated: April 26, 2023

MySQL also support multiple data inserting in single INSERT INTO query. For bulk data inserting, it helps inserting data by a single query efficiently. 

Syntax:

INSERT INTO table_name (column1, column2, column3, ...) VALUES (value1, value2, value3, ...), (value1, value2, value3, ...), (value1, value2, value3, ...), (value1, value2, value3, ...), ... ;

Insert 3 data in one query(Using first syntax):

INSERT INTO contact
(id, age, mobile, name, address, city, country)
VALUES
(9, 75, "0723949243", "Atiur Galib", "Khulna, BD", "Khulna", "BD"), 
(10, 29, "0179320942", "Kuddus", "Istambul, Trukey", "Istambul", "Turkey"), 
(11, 21, "0172384792", "Michel Reo", "Paris, France", "Paris", "France");

Insert 3 data in one query(Using second syntax):

INSERT INTO contact VALUES 
(12, "George", 17, "017437625", "Berlin, Germany", "Berlin", "Germany"),
(13, "James", 17, "0179329389", "London, UK", "London", "UK"),
(14, "Nenson Lio", 65, "017934721", "London, UK", "London", "UK");

Related post