Stack Stack - 1 year ago 78
MySQL Question

How can I insert multiple rows in the same table by one query?

I have two insert queries like these:

INSERT INTO mytable VALUES('NULL',name1)('NULL',name2)

Those two
queries above, add two separated rows to
. Well can I do that via single query?

Answer Source


INSERT INTO mytable (id, name) VALUES 
(NULL, :name1),
(NULL, :name2)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download