SQL: Split string by delimiter multiple times into new columns -


i have ids , corresponding strings this:

id    place 234   usa_ny_buffalo 

i want split place string 3 strings each own column:

id    country  state  city 234   usa      ny     buffalo 

when try splitting string this:

select id, split(place,"_") mytable 

i

id    place 234   usa 234   ny 234   buffalo 

is possible split string first "_", split second string again " _ " ?

if string have country,state , city try like.

select substring_index('usa_ny_buffalo', '_', 1) country, substring_index(substring_index('usa_ny_buffalo', '_', 2), '_', -1) state, substring_index(substring_index('usa_ny_buffalo', '_', 3), '_', -1) city; 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -