Last active
August 29, 2015 14:04
-
-
Save clhenrick/13f6cfd8dab745948e4c to your computer and use it in GitHub Desktop.
split column into rows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- split the name_alt column into new rows using `|` as a delimiter and insert into global_province_synonyms table as new rows | |
-- to do: do a `IS NOT null` check? | |
-- note: you have to escape the | character as it is reserved in Postgres | |
INSERT INTO global_province_synonyms (name, rank, woe_id, country_iso3) | |
SELECT | |
regexp_split_to_table(global_province_polygons.name_alt, E'\\|' ) AS name, | |
1, woe_id, iso3 | |
FROM | |
global_province_polygons |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment