View Full Version : SQL query to insert muliple records with different email address

06-07-2011, 09:10 PM
Hi guys.

I have the following query

INSERT INTO `cork_wall`.`Classified` (
`id` ,
`user` ,
`description` ,
`link` ,
`img1` ,
NULL , 'corkdjs@gmail.com', 'Hi guys.', '', 'http://munsterweddingdjs.com/images/weddings-in-east-cork.jpg', '0'

how do i insert the same record multiple times but changing the email address each time to the following emails...

email3@hotmail.com etc

is there any quick way of doing it besides writhing out a different query for each email address?

Old Pedant
06-07-2011, 09:49 PM
The best you can do is provided by MySQL (only) via:

INSERT INTO table ( field1, field2, field3 )
VALUES ( x, y, z ), ( a, b, c ), ( .... )

That is, you simply repeat the insert values, in parens, once for each set of values you want to insert.

I don't know of any other DB that allows this, so you are lucky you are using MySQL.