-3
How can I cut the name of a string coming from Mysql to get name, middle name and last name, I’m trying and I’m not getting, what I have so far is this, but I need the middle name and middle name to be together and separate last name
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(Nome, ' ', 1), ' ', -1) AS first_name, If(length(Nome) - length(replace(Nome, ' ', '')) > 1, SUBSTRING_INDEX(SUBSTRING_INDEX(Nome, ' ', 2), ' ', -1) ,NULL) as NomeMeio, SUBSTRING_INDEX(SUBSTRING_INDEX(Nome, ' ', 3), ' ', -1) AS ÚltimoNome FROM cadColaborador
What I need is this:
Nome: ABEL DE Sobrenome: CAMARGO
How to differentiate between composed surnames and middle names?
– Woss
If I were you, I would change the structure of your table, instead of creating a table with the fields "name, middle name and last name", create a table with only the name and last name. If the person has a middle name like "John Paul", add name in the field.
– João Paulo