Wednesday, 15 September 2010

mysql - How to convert surnames beginning with O xxx to O'Xxx and those beginning with Mc xxx to McXxx -



mysql - How to convert surnames beginning with O xxx to O'Xxx and those beginning with Mc xxx to McXxx -

i know alter should have been made before info entered database tell me if there way convert names in surnames column origin o xxx o'xxx , origin mc xxx mcxxx.

thanks 1000000 in advance help.

you utilize quick solution this:

update surnames set surname = case when surname 'o %' concat('o\'', substring_index(surname, 'o ', -1)) when surname 'mc %' concat('mc', substring_index(surname, 'mc ', -1)) end surname 'o %' or surname 'mc %'

see fiddle here.

mysql sql

No comments:

Post a Comment