sql - Parsing underscore delimited fields in MySQL -


i have following table:

patent      assigneename                        assigneeunparsed -------     --------------                      --------------- d452605     louis vuitton malletier, s.a.       paris_none_fr d452606     nike, inc.                          beaverton_or_us d452607     salomon s.a.                        metz-tessy_none_fr 

i have searched site , cant find specific on how explain parsing underscored field separate fields. want take assigneeaddress field , parse 3 fields (assigneecity, assigneestate, assigneecountry)

can explain how or point me tutorial can attempt figure out?

select      substring_index('beaverton_or_us', '_', - 1) assigneecity,     substring_index(substring_index('beaverton_or_us', '_', 2),             '_',             - 1) assigneestate,     substring_index('beaverton_or_us', '_', 1) assigneecountry; 

update :

update tablename  set      assigneecity = substring_index('beaverton_or_us', '_', - 1),     assigneestate = substring_index(substring_index('beaverton_or_us', '_', 2),             '_',             - 1),     assigneecountry = substring_index('beaverton_or_us', '_', 1); 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -