Jump to content

Change case in a mySql DB?


izbryte

Recommended Posts

I have a checkbox field in a mysql database that is fed through a form on a website and I accidentally forgot to capitilize the first letter (word should be Word). It is part of an array. Now there are 100's of listings. Is there an easy way for me to go in change them all at one time in phpmyadmin?

Link to comment
https://forums.phpfreaks.com/topic/120927-change-case-in-a-mysql-db/
Share on other sites

there's no handy function, according to the manual, to do this in a MySQL query, but you can use a combination of them:

 

UPDATE table SET field=CONCAT(UPPER(LEFT(field, 1)), RIGHT(field, CHAR_LENGTH(field) - 1))

 

this will set field equal to the uppercase version of the first character followed by the remainder of the value as it was. i would duplicate your data into a test table to check that it works there first, before you go and operate this directly on your dataset.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.