update Mysql table from another table.
I recently changed video servers and needed to update several hundred video reference codes that were held in a MySql database. I have two tables, one of which contains the video title and the old embed code, and another table with the video title and the new reference codes. The title of the videos is exactly the same in both tables, so I am able to use the video tile field to link the two tables.
In looking for the method, I found the reference documents to be rather foggy, so I thought I’d post the solution that worked for me.
I downloaded a trial copy of Navicat (you need the full version) in the query editor I entered the following code:
——————————
UPDATE table_a
INNER JOIN table_b
ON table_a.field_x=table_b.field_y
SET table_a.field_title=table_b.field_title
———————————
In the code above, table_a is the table that contains field_x which is to receive the data, table_b contains field_y which has the data to be updated into table_a. The fields that act as the key contain the same data are field_title in table_a and field_title in table_b.
It worked like a charm!

Leave a Comment