mbrc
mbrc

Reputation: 3953

mysql update script problem. all txt is lower case just first letter is upper case

This are my text in mysql database.

Otok Pasman, Kraj
Otok pasman,Kraj
Otok Pasman , Kraj
Otok pasman, Kraj
Otok PASMAN, Kraj

How can i automatically change all rows to lower case, first letter must be upper case and " , " is always ", "?

so like this:

Otok Pasman, Kraj

and all other text in database like this example?

Upvotes: 2

Views: 425

Answers (1)

Dmitry Samuylov
Dmitry Samuylov

Reputation: 1564

something like this should work:

UPDATE `table` 
SET `field` = REPLACE(CONCAT(UPPER(LEFT(`field`, 1)), LOWER(SUBSTRING(`field`, 2))),' , ', ', ')

Upvotes: 2

Related Questions