Reputation: 9679
How can MySQL insert multiple records by executing a single insert statement?
The problem at hand involves 1 to 10 records, depending upon user input.
Upvotes: 6
Views: 15765
Reputation: 1108702
Just separate the values by comma.
INSERT INTO
tablename (colname1, colname2, colname3)
VALUES
('foo1', 'bar1', 'waa1'),
('foo2', 'bar2', 'waa2'),
('foo3', 'bar3', 'waa3')
Upvotes: 11