You got it!! That is the easiest way to duplicate data while
changing(setting) certain columns to new values.
WTG!
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine
Scott Haneda
<[EMAIL PROTECTED] To: MySql <[EMAIL PROTECTED]>
> cc:
Fax to:
06/28/2004 02:43 Subject: Re: Duplicate selection with
change
AM
on 06/27/2004 11:31 PM, Scott Haneda at [EMAIL PROTECTED] wrote:
> So, I need to basically:
> SELECT iamge_title, image_filename, image_url, image_width, image_height
> from images where user_id = '123';
>
> Then, take that result and insert all those rows in the same table,
setting
> type='2' and added=NOW()
>
> I think I need to do a subselect, the docs are really sparse on examples,
> and I don't see how to change the 2 values I need to change.
I may have just made this work in my simple testing, unless someone can
tell
me a better, way, this is what I came up with:
insert into images (user_id, image_title, image_filename, image_url, type,
added) select user_id, image_title, image_filename, image_url, '4', NOW()
from newsletter_images where user_id = '123';
So basically, since I need to select the SAME fields I am inserting, just
select the 2 that I need to change the data in, ignore what they may or may
not have, and drop in hard values in the select statement.
--
-------------------------------------------------------------
Scott Haneda Tel: 415.898.2602
http://www.newgeo.com Fax: 313.557.5052
[EMAIL PROTECTED] Novato, CA U.S.A.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]