Jump to content

Copy a field with phpMyAdmin?


jonnewton

Recommended Posts

Is there an easy way to duplicate or copy a MySQL field in phpMyAdmin other than just copying/pasting the data from one field to another? I don't see any buttons that do that. The help docs say you can do it, but I can't find where it says how. Any help greatly appreciated.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.