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
SELECT * 
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?

Recommended Answers

All 2 Replies

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.