dbTalk Databases Forums  

What is the equivalent of StrConv(field_name, 3) of MS Access in MySQL

comp.databases comp.databases


Discuss What is the equivalent of StrConv(field_name, 3) of MS Access in MySQL in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Leader
 
Posts: n/a

Default What is the equivalent of StrConv(field_name, 3) of MS Access in MySQL - 07-29-2003 , 03:19 AM






HI,
i got a problem while using StrConv function of MS Access in MySQL.
My requirement is:-
suppose in a name field i have "jhon smith" Now i want to run a sql
which will give me the result like "Jhon Smith"--which means upper
case first.

Now i am running a query like below which is giving me "Jhon smith"
but i want "Jhon Smith".

SELECT [CustomerID] ,upper(left(firstname,1)) + lower(right(firstname,
len(firstname)-1)) AS [FirstName_] from my_table;


But the above query is not giving me the right result. Please
suggest...


Thanks
Hoque

Reply With Quote
  #2  
Old   
Leader
 
Posts: n/a

Default Re: What is the equivalent of StrConv(field_name, 3) of MS Access in MySQL - 07-30-2003 , 01:16 AM






lennart (AT) kommunicera (DOT) umea.se (Lennart Jonsson) wrote in message news:<6dae7e65.0307291031.110c4a47 (AT) posting (DOT) google.com>...
Quote:
sohelcsc (AT) yahoo (DOT) com (Leader) wrote in message news:<b1a93c73.0307290019.5036cc24 (AT) posting (DOT) google.com>...
HI,
i got a problem while using StrConv function of MS Access in MySQL.
My requirement is:-
suppose in a name field i have "jhon smith" Now i want to run a sql
which will give me the result like "Jhon Smith"--which means upper
case first.

Now i am running a query like below which is giving me "Jhon smith"
but i want "Jhon Smith".

SELECT [CustomerID] ,upper(left(firstname,1)) + lower(right(firstname,
len(firstname)-1)) AS [FirstName_] from my_table;


But the above query is not giving me the right result. Please
suggest...


Thanks
Hoque

In general I would say that it is better to keep firstname and
lastname in different columns. I assume this is not an option for you
so you might try:

select
upper(substr(name,1,1)) || -- begin firstname
lower(substr(name,2,locate(' ',name)-2)) || -- end firstname
' ' ||
upper(substr(name,locate(' ',name)+1,1)) || -- begin lastname
lower(substr(name,locate(' ',name)+2)) -- end lastname
from mytable

Note that this does not handle names like 'Edgar Alan Poe' nor names
like 'Prince'

HTH
/Lennart
Hi Lennart,
your given query is not working because of funciton substr and ||
.....but i came up with a new query which is as follows

select
concat(Concat(upper(substring(name,1,1)),
(lower(substring(name,2,locate(' ',name)-2)))), ' ' ,
concat(upper(substring(name,locate('
',name)+1,1)),(lower(substring(name,locate(' ',name)+2)))))
from mytable;

anyway...thanks for everything...

Hoque


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.