Mysql extract first letter of each word in a specific column

后端 未结 5 1765
予麋鹿
予麋鹿 2021-01-16 02:36

I want to create an acronym column in a table. I want to be grab the first letter of each word from a \'name\' column, capitalize it, then concatenate all into an \'acronym\

5条回答
  •  长情又很酷
    2021-01-16 03:09

    This should get all the first letters into a result set:

    SELECT UPPER(SUBSTR(name, 0, 1)) FROM the_table
    

    Concatenating them all into a single acronym would, I think, require a procedure of some kind. I don't think it can be done in a statement.

提交回复
热议问题