Skip to content

Instantly share code, notes, and snippets.

@mrpunkin
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrpunkin/7582190563863a84a904 to your computer and use it in GitHub Desktop.
Save mrpunkin/7582190563863a84a904 to your computer and use it in GitHub Desktop.
Trying to update woeid on geoplanet_adjacencies with matching replacement_woeid from a changes.tsv file in MySQL.
CREATE TEMPORARY TABLE geoplanet_changes (
woeid BIGINT(20) NOT NULL PRIMARY KEY,
replacement_woeid BIGINT(20) NOT NULL,
data_version VARCHAR
);
LOAD DATA INFILE 'infile.tsv' INTO TABLE geoplanet_changes
FIELDS TERMINATED BY '\\t' OPTIONALLY ENCLOSED BY '\"'
(woeid, replacement_woeid, data_version);
SHOW COLUMNS FROM geoplanet_adjacencies;
UPDATE geoplanet_adjacencies, geoplanet_changes
SET geoplanet_adjacencies.woeid = geoplanet_changes.replacement_woeid
WHERE geoplanet_adjacencies.woeid = geoplanet_changes.woeid;
DROP TEMPORARY TABLE geoplanet_changes;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment