Matt Alexander said:
> Mike Starke said:
>> On Mon, Sep 22, 2003 at 02:05:32PM -0700, Matt Alexander wrote:
>> /_Mike Starke said:
>> /_>
>> /_> Is there a function in MySQL similar to that in Excel's
>> "proper()"? /_>
>> /_> For instance, I would like to do a select on a column that has /_>
>> all CAPS and display the query in proper case (Mike versus MIKE). /_
>> /_select
>> concat(ucase(left(first_name,1)),lcase(SUBSTRING(first_name,2))) /_as
>> First_Name from myTable;
>>
>> Thanks. Getting closer. My problem is when you have a value like "MR.
>> FUDDS DELI"
>> in the column; you get "Mr. fudds deli" instead of "Mr. Fudds Deli".
>
> Hooboy... it doesn't get much worse that this, but here goes:
>
> select
> replace(replace(replace(replace(replace(replace(replace(replace(replace(
> replace(replace(replace(replace(replace(replace(replace(replace(replace(
> replace(replace(replace(replace(replace(replace(replace(replace(concat(
> ucase(left(first_name,1)),lcase(substring(first_name,2))),' a',' A'),'
> b', ' B'),' c', ' C'),' d', 'D'), ' e', ' E'),' f', ' F'),' g', ' G'),'
> h', ' H'),' i', ' I'),' j', 'J'),' k', ' K'), ' l', ' L'),' m', ' M'),'
> n', ' N'),' o', ' O'),' p', 'P'),' q', ' Q'),' r', ' R'), ' s', ' S'),'
> t', ' T'),' u', ' U'),' v', 'V'),' w', ' W'),' x', ' X'),' y', ' Y'), '
> z', ' Z')
> as Name from myTable;
Really you need to account for " a" as well "a " for our friends in the
south like Billy Joe Jim Bob.... ;) As you can see it is possible to do
as stated with "bastardization" of string functions. :) Not impossible,
just ugly. What really makes this suck is that you can't turn it into a
function so EVERY field of EVERY view/table you want to do this you have
to redo this madness. Folks that dont like to argue about inferiorities
of MySQL please make note of this.
-Derek