mysql - Splitting name column with multiple delimiters -
i'm trying split name column (fullname) format lastname, firstname 2 separate columns in mysql using:
select substring_index(substring_index(fullname, ',', 1), ' ', -1) firstname, substring_index(substring_index(fullname, ',', 2), ' ', -1) lastname tablename; this works on most names. however, name "del torres jr, marcelo" shows
-------------------- lastname | firstname -------------------- jr | marcelo -------------------- how need alter statement capture of name after comma?
can not use:
select substring_index(fullname, ',', 1) firstname ,substring_index(fullname, ',', -1) lastname table i can't tell you're trying match against ' ' if you're trying trim whitespace can use trim() on values.
Comments
Post a Comment