Yes! but you will have to do some typing....

Just use the INSERT ... SELECT command. You do NOT want list the PK column
in your statements (so that it will autoincrement) so you will have to type
out the rest of the column names. With a table that looks like:

CREATE TABLE testme (
id int auto_increment primary key,
col1 int,
col2 int,
...
col37 int
)

You would use a statement like:
INSERT testme (col1, col2, ..., col37)
SELECT col1, col2, ... , col37
FROM testme
WHERE <conditions go here>

Whatever rows the WHERE clause matched would be added to the table creating
your duplicate rows. Because you DID NOT list the autoincrement column, all
of those new rows end up with new numbers.

Now, if you know what changes to you want to make at the time of the
copying, you can define those changed in the SELECT statement and do it all
at once.

SELECT (col1 + 1, col2 +1, col3, ...

That would give you incremented numbers for col1 and col 2 but the rest of
the fields would be the same, get it?

HTH,
Shawn Green
Database Administrator
Unimin Corporation - Spruce Pine



                                                                                       
                                   
                      John Mistler                                                     
                                   
                      <[EMAIL PROTECTED]        To:       <[EMAIL PROTECTED]>          
                                
                      phia.net>                cc:                                     
                                   
                                               Fax to:                                 
                                   
                      06/10/2004 03:40         Subject:  COPY row?                     
                                   
                      PM                                                               
                                   
                                                                                       
                                   
                                                                                       
                                   




Is there a COPY row or DUPLICATE row command?  I would like to duplicate a
row with in a table with 38 columns (auto-incrementing the Primary Key on
the copied row, of course) and then alter the entry in ONE of its columns.
Can this be done without doing a SELECT, then INSERT, then UPDATE?

Thanks,

John


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

Reply via email to