Can you roughly outline the schema of the two tables?

If the key value doesn't have to match from the input to the final result,
you can always insert into a list of fields, skipping the auto_increment/key
column, and they will continue to be generated..

Assuming you have two tables with id_col, col2, col3:

INSERT INTO table (col2, col3)
SELECT col2, col3 FROM table2 WHERE id_col=1;


Regards,

Matt

-----Original Message-----
From: Eric J. Janus [mailto:[EMAIL PROTECTED] 
Sent: 29 March 2004 19:37
To: MySQL
Subject: INSERT ... SELECT question

I have a table with just about 100 columns, and I would like to duplicate a
row exactly, except for one column, which is the AUTO_INCREMENT column.

Using 'INSERT INTO tbl_name SELECT * FROM tbl_name WHERE id_col = 1' doesn't
work, because it produces the following error: 'ERROR 1062: Duplicate entry
'1' for key 1'.

Because I'd like the application using this database to be simpler to
maintain, I'd prefer to not have to change the code each time a field is
added...so is there a way to duplicate a row, but still have it
automatically assigned an value for the AUTO_INCREMENT column?

Thanks,

Eric


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

  • ... ΝΙΚΟΣ ΓΑΤΣΗΣ
    • ... Nitin
      • ... ΝΙΚΟΣ ΓΑΤΣΗΣ
    • ... Fortuno, Adam
    • ... Eric J. Janus
      • ... Matt Chatterley
        • ... Eric J. Janus
          • ... Matt Chatterley
            • ... Eric J. Janus
    • ... Henrik Schröder
      • ... Eric J. Janus

Reply via email to