mySQL query statement to copy/paste fields from one table to another

Not surprisingly, the New Blog Template plugin cannot copy Theme settings.

What is surprising is how difficult it is to find a mySQL query statement to do this in the database.

If someone can help provide a workable and understandable solution, I believe it would help a lot of people

basically –

need to copy fields (but not all) from one table into another table, replace existing content and/or add row if they don’t exist.

tables have identical structure in the same database, they are: wp_source_options and wp_target_options

columns are option_name and option_value

basically, if option_name field = “condition1” (“template” for example) is present in targettable copy option_value field from sourcetable and replace targettable option_value field, if not present then add it

would like to update/replace multiple fields with one query. There are five or six fields that would need to be copied (in the theme I have). It would be acceptable to run two queries – the first to UPDATE and the second to INSERT. or REPLACE? Another issue is that REPLACE might not be available in all phpMyAdmin

the problem seems to be that all suggestions I’ve found go to replace ALL the fields in a column which wreaks things, column_id won’t work because of different id’s between tables.

Any mySQL gurus out there?

  • Kimberly
    • Champion of Loops


    Thanks for using WPMU forums :slight_smile:

    I may have a solution for you – have you tried out Navicat?

    To help ease the pain and assist dealing with copying tables in the database, I offer you to download in what is in my opinion the greatest Database Management software of all time Navicat.

    That could definitely do the job for you – I would love to hear how it goes if you try it out?



  • tripvendor
    • The Bug Hunter

    Hi Kimberly –

    It took me awhile to figure out how to get it connected to my server, but once up and going Navicat is sort or revolutionary (or evolutionary) for dealing with mySQL. I look forward to digging in to see what kind of damage I can wrought.


Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.