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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.