SQL Multiple inserts

Always forget this one at first but to do multiple inserts into a tabel you can use the following:

INSERT INTO tblName (name, age)
VALUES
('Andy', 26),
('Helen', 21),
('Justin', 23),
('Leighton', 25);

Posted: 13-Dec-2004

View: 20409

Permalink: here

Comments

Does this work with MSAccess too?

#1 Ryan Guill
13/Dec/04 6:19 AM

Nice.. Didn't know that one!

#2 Darryl Lyons
13/Dec/04 3:01 PM

Ryan, should work with Access though i've not got one setup currently to try

#3 Andy Jarrett
13/Dec/04 5:20 PM

With MySQL, at least, you can also do INSERTS like an UPDATE statement. That is: INSERT INTO tblName SET name = 'Andy', age = '26'; Only get one insert per query that way, but it can be handy for large insert statements that are otherwise unreadable.

#4 Barneyb
15/Dec/04 6:26 PM