A quick article on how to populate a database column from another table using a string comparison.
Why?
I have several database tables which replicate country names and I would rather they all use the ccTLD two letter code. This article was written because it took me so long to work it out.
How?
UPDATE `table_to_update` a
INNER JOIN `table_to_read` b
ON a.`CountryName` COLLATE utf8_general_ci LIKE b.`CountryName` COLLATE utf8_general_ci
SET a.`ccTLD` = b.`ccTLD`
Discussion
Comments
Questions, corrections and useful additions are reviewed before appearing here.
No comments yet. Start the discussion.