Tags
Asked 2 years ago
17 Jun 2021
Views 308
Era

Era posted

Insert multiple rows with one query MySQL

Insert multiple rows with one query MySQL
sec8

sec8
answered Apr 28 '23 00:00

To insert multiple rows with one query in MySQL, you can use the INSERT INTO statement followed by a list of values for each row to be inserted, separated by commas. Here's an example:



INSERT INTO my_table (column1, column2, column3)
VALUES
  ('value1', 'value2', 'value3'),
  ('value4', 'value5', 'value6'),
  ('value7', 'value8', 'value9');

In this example, my_table is the name of the table you want to insert rows into, and column1 , column2 , and column3 are the names of the columns you want to insert data into. Each set of values in parentheses represents one row to be inserted.

Make sure that the number of values you provide matches the number of columns you are inserting data into, otherwise you will get an error.
Post Answer