Jump to content

Copy a field with phpMyAdmin?


jonnewton

Recommended Posts

I have complex records who share a lot of the same data. It would be great to set up one record, duplicate it, then just replace the data in the few fields that are different.

 

I did export a field, for which there is a button in phpMyAdmin. I used default settings. When I tried to import it, it gave me an error message that I was trying to import a duplicate table. I opened the export into a text editor and copied the INSERT portion into the SQL box in the original table. I had to change the data in the primary key field to NULL (it's an auto-increment int field), but then it added the record no problemo. I probably could have exported with some other format, but...

 

This isn't that bad, but it would be great to just be able to hit a "Duplicate Record" button--guessing there isn't one?

You could use INSERT INTO... SELECT WHERE... to "duplicate"... just copy whatever values to want in the select, and add string values for anything else, e.g.:

 

INSERT INTO yourTable ( col1, col2, col3, col4) SELECT 'newcol1value', col2, col3, 'newcol4value' FROM yourTable WHERE uid = <the-source-record's-uid>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.