Good day. Faced this problem: There is a table oc_product_desctiption ~ 3K records, of which in 96 the meta_title field is empty. Next to it is the oc_product_old table in which this field is empty for only 10 entries. How can I fill in the empty fields of the first table with the fields of the second (with a coincidence in the product_id field)? Tried like this:

SELECT * FROM oc_product_description AS a WHERE meta_title = "" UPDATE * FROM oc_product_description_old AS b WHERE b.product_id = a.product_id; 

The select works, on an error, I have rather poor knowledge in this area, I really hope for help.

    2 answers 2

    Solution to the forehead:

     UPDATE oc_product_description a SET a.meta_title = ( SELECT meta_title FROM oc_product_description_old b WHERE b.product_id = a.product_id) WHERE a.meta_title = ''; 
    • Thank you very much! - f4rr3ll

    Why not just

     UPDATE oc_product_description a, oc_product_description_old b SET a.meta_title = b.meta_title WHERE a.product_id = b.product_id AND a.meta_title = ''