Forum Moderators: open

Message Too Old, No Replies

ucwords like function in mysql

ucwords like function in mysql

         

kirang

8:04 am on May 8, 2008 (gmt 0)

10+ Year Member



Hello,

Is there any function available in mysql which is similar to ucwords function of php [php string function ucwords to change all first character of words present in a string to upper case or capitalize the first letter of each word.]?

If not, is there any way we can update the data directly in mysql using any form of query.

Thanks in advance.

rocknbil

10:24 pm on May 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, there is the upper() [dev.mysql.com] (synonymous for ucase() ) function that will return all characters in upper case, you could combine that with the substr() [dev.mysql.com] (syn.: substring() ) function to apply it to just the first letter.

But that won't update the database, just alter it on select. I'm guessing you will have to script it out to actually modify the data.

coopster

7:59 pm on May 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Or run an UPDATE on the field, using the same expression in the assignment operation as was used in the SELECT clause ;)