From: "Lee Denny"
> site_id, page_id,header_text,main_text..
>
> I just need to duplicate existing records with a new site_id, so :
>
> 1,1,Hello,some text..
> 1,2,Hello Again, some more text...
>
> gets copied to
>
> 2,3,Hello,some text..
> 2,4,Hello Again, some more text...
>
> page_id is already auto_increment.
>
> I'm sure that an INSERT .. SELECT statement should do it, but I'm unsure
of
> the correct syntax.
>

INSERT INTO `<tablename>` SELECT <new_site_id>, NULL, `header_text`,
`main_text` FROM `<tablename>` WHERE `site_id`=<old_site_id>

NULL will let MySQL use the autoincrement...
Tested on 4.0.23-standard

Regards, Jigal.


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to