How do I update mySQL to have first letter uppercase?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
simonmlewis
DevNet Master
Posts: 4434
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

How do I update mySQL to have first letter uppercase?

Post by simonmlewis »

I need to update all the entries in a db field, so the first letter is UPPERCASE.
I've looked online and there seems to be a few ways, but each time i try it, it errors.

Code: Select all

mysql_query("UPDATE pages SET title = UC_Words(title) WHERE id = '$row->id'");
This doesn't work. I get the message:
[text]#1305 - FUNCTION website.CAP_FIRST does not exist [/text]
Is it because this is "old"??
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6425
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How do I update mySQL to have first letter uppercase?

Post by Celauran »

There is no MySQL function UC_Words. You will likely want to use UPPER and SUBSTRING.
User avatar
Christopher
Site Administrator
Posts: 13595
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: How do I update mySQL to have first letter uppercase?

Post by Christopher »

I searched the Interwebs and found this pretty quickly:

http://www.artfulsoftware.com/infotree/ ... php?id=122
(#10850)
Post Reply