paul bennett

MySQL multi insert

Posted on: October 29, 2007

I really wish I’d known this a long, long time ago:

insert into `mytable` (fname, lname, address) values ("john", "doe", "123 some st"), ("jane", "doe", "456 other st")

This wee gem allows an application to add multiple rows to a table in one simple query.

Say goodbye to those processor intensive loops…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives

%d bloggers like this: