How to massively change string capitalization in a table?
-
06-03-2021 - |
Pergunta
I have a project where authors' names have been inserted in all capital letters (ex. JOHN KRAUS, LEONARD MILES, NAOMI DAWSON). Now I need these values in "normal" case (ex. John Kraus, Leonard Miles, Naomi Dawson)
How can I achieve that?
Solução
Mysql
has a mechanism called cursors
that allows to read all the rows from the table one by one. Detailed description can be found here:
https://dev.mysql.com/doc/refman/8.0/en/cursors.html
You have to write a stored routine with a cursor loop inside and to place some case transforming logic in it. Useful functions are LOWER(), UPPER(), SUBSTRING() and other text functions described here:
https://dev.mysql.com/doc/refman/8.0/en/string-functions.html
Licenciado em: CC-BY-SA com atribuição
Não afiliado a dba.stackexchange