Skip to content

Capitalize first letter only in USA customer name

Need a MySQL query to update the customer first letter of the name is Capitalized and the remaining letters are lower case.

In cases where the Last name begins with the following: (Fitz, Mac, Mc, and O’) we should capitalize the following letter:

Example: McDonald, MacIntyre, O’Neal, etc.

I expect the output of to “mcdonald, macintyre, o’neal” be “McDonald, MacIntyre, O’Neal”

Advertisement

Answer

To do last name transformation in MySQL you would need to do something like this.

NOTE: this is merely handling the ‘macdonald => MacDonald’ scenario.

Just add more ‘when’ statements for the other cases (or special cases)

User contributions licensed under: CC BY-SA
9 People found this is helpful