4.0.18-standard

I need to duplicate a select of records, all in the same table, but also
make a change to one field.

Here is one table I need to do this on
+----------------+---------------+------+-----+----------------+
| Field          | Type          | Null | Key | Default        |
+----------------+---------------+------+-----+----------------+
| id             | int(11)       |      | PRI | NULL           |
| user_id        | int(11)       |      |     | 0              |
| image_title    | varchar(48)   |      |     |                |
| image_filename | varchar(32)   |      |     |                |
| image_url      | varchar(255)  |      |     |                |
| image_width    | int(3)        |      |     | 0              |
| image_height   | int(3)        |      |     | 0              |
| type           | tinyint(1)    |      |     | 0              |
| updated        | timestamp(14) | YES  |     | NULL           |
| added          | timestamp(14) | YES  |     | 00000000000000 |
+----------------+---------------+------+-----+----------------+

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.
-- 
-------------------------------------------------------------
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]

Reply via email to