Convert Names from ALL CAPS (or all lower) to Mixed Case in SQL

Preface: use LENGTH for MySQL, LEN for Transact-SQL (SQL Server). I copied the following code from one of my MySQL instances. Couldn’t figure out initially why LEN wasn’t working, before I remembered that I was still thinking in Transact-SQL instead of MySQL. Yay for industry standards! </sarcasm>

   lower(right(first_name, length(first_name) - 1))) as [whateverAlias],
   lower(right(last_name, length(last_name)-1))) as [whateverAlias]

upper(left(first_name,1)) grabs the first character of your first_name field and changes it to upper case.

lower(right(first_name, length(first_name)-1)): Taking the total length of the first_name field, then subtracting 1, go from the right that many characters, since we’re skipping the first character. Change that to lower case. Remember to use LEN instead of LENGTH in Transact-SQL

concat (….) as whatever: concatenates the upper case letter and lower case remainder into a new whatever value that’s more easy to remember than upper(left(first……).