MySQL Tutorial – How to Insert Multiple Records

Insert multiple records in a single query

To insert multiple records in a single query, each record is enclosed in parentheses and is separated by a comma. Here is the syntax of inserting multiple records in a single query.

INSERT INTOtable_name
(column1, column2, column3, etc…)
VALUES
(value1, value2, value3, etc…),
(value1, value2, value3, etc…),
(value1, value3, value3, etc…);

We have here an example of inserting multiple records in a single query:

INSERT INTO employee_record
(f_name, l_name, position, age, salary, email)
VALUES
(“Sam”, “Milby”, “System Analyst”, 34, 20000, “sammilby@yahoo.com”),
(“John Lloyd”, “Cruz”, “Network Administrator”, 33,       20000,”johnlloydcruz@yahoo.com”);

Once you have encoded the command correctly, it will display a success message.

Ex. Query OK, 1 row affected (0.00 sec)

Note: using this technique will make your work faster and it will improve the processing performance of your database.

, , ,

Post navigation

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.