...

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



kevinkhan
06-07-2011, 08:10 PM
Hi guys.

I have the following query


INSERT INTO `cork_wall`.`Classified` (
`id` ,
`user` ,
`description` ,
`link` ,
`img1` ,
`published`
)
VALUES (
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...

email1@hotmail.com
email2@hotmail.com
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, 08: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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum