nectar
nectar

Reputation: 9679

Inserting more than one record with a single insert statement

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

Answers (1)

BalusC
BalusC

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

Related Questions