My Table column -

My expected Output to change in column -
Smith, Allen, Doyle, Dennis, Baker, Waker
This is what i tried, but not working :( -
UPDATE TABLE `employee` SET last_name = UCASE(LEFT(lower(last_name), 1)) UPDATE TABLE `employee` SET last_name = ucase(lower(last_name),1)
Followed this link too - Resource
ERROR --
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TABLE `employee` SET last_name = UCASE(LEFT(lower(last_name), 1))' at line 1
Let me know what I am doing wrong and how to fix.
try this it may work
update `employee` set name=concat(left(upper(last_name),1),right(lower(last_name),length(last_name)-1)); In case someone here is looking also how to upper case First Name and Last Name in say a Name column that contains both, here is a snippet that maybe useful:
SELECT CONCAT( UCASE(LEFT(substring_index(name, ' ',1),1)), LCASE(SUBSTRING(substring_index(name, ' ',1),2)), ' ', UCASE(LEFT(substring_index(name, ' ',-1),1)), LCASE(SUBSTRING(substring_index(name, ' ',-1),2)) ) as name FROM table
No comments:
Post a Comment