MYSQL query to copy all data in a column from one database to another
P粉005417748
P粉005417748 2024-04-01 00:00:37
0
1
476

I accidentally used the "Generate Description" feature on the Opencart SEO tool and it overwrote all of my product descriptions with the product title.

I have over 600 products and it would be a pain to remake them all.

I have a MYSQL backup that is 2 months old and contains most of the products except about 20 that were added later.

I have imported an old backup into a newly created database, what query can I run to copy and overwrite all the description column data from the backup table into the current table?

They are located at database.oc_product_description.description

Any help is greatly appreciated. This is driving me crazy

P粉005417748
P粉005417748

reply all(1)
P粉476475551

If the two schemas are located in the same MySQL instance, please use the REPLACE INTO statement (backup before operation)

means: restored database Database means: current database

REPLACE INTO database.oc_product_description 
 SELECT * FROM old.oc_product_description

This statement will replace the data with the primary key

If you don't want to copy the entire table, do an update and copy the data from the old table to the database (product_id and language_id columns are primary keys)

UPDATE database.oc_product_description AS pd1
 INNER JOIN old.oc_product_description AS pd2 ON pd2.product_id = pd1.product_id 
                                             AND pd2.language_id = pd1.language_id
  SET pd1.description = pd2.description
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!