I have a MySQL Database with several tables that have the same fields in them. I have updated the "cp_ads_welcome_msg" field of the "WP_7_OPTIONS" table with the data that I would like to update all the other tables with. This code works if wanted to update each table one at a time.

REPLACE INTO wp_9_options
FROM wp_7_options
WHERE wp_7_options.option_name = "cp_ads_welcome_msg";

There are 650 tables though. I would like to know how I could update all tables at the same time. The tables are named "WP_XXX_Options"
I have tried manipulating this code as much as I can figure out, but nothing works. Can someone help me out here?

Edited by Ezzaral: Fixed code tags

6 Years
Discussion Span
Last Post by EmilyJohnson

I think you should use a separate table to store the "cp_ads_welcome_msg" field and use foreign key on all the "WP_XXX_Options" to reference the "cp_ads_welcome_msg" field.

By doing this, you only need to update one table and all the "WP_XXX_Options" will point to the same "cp_ads_welcome_msg".

Hope it helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.