Updating table with values from another table

I have a database of interesting words on my server that has pronunciations and definitions. On another server, I want to create a database of boring words. Since there is some overlap, I thought I would save some time and populate the new database with pronunciation and definitions from the old one. It is fairly straightforward, just remember to put in the commas to separate the where conditions. I’m using phpMyAdmin and while I don’t think the backtics are required, I go in the habit of using them from writing PHP code. Even though you are only updating one table, you need to put both in the update line.


UPDATE `boring_words`,  `interesting_words` 
SET `boring_words`.`pronunciation` = `interesting_words`.`pronunciation`,
    `boring_words`.`definition` = `interesting_words`.`definition`,
    `boring_words`.`comment` = `interesting_words`.`comment`
WHERE `boring_words`.`word` = `interesting_words`.`word`;

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.