Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change one lowercase letter to an UPPERCASE in MySql

Status
Not open for further replies.

HowdeeDoodee

Technical User
Joined
Mar 14, 2005
Messages
61
Location
US
I have a MySql table and I need to change all lowercase letters preceded by a left parens to uppercase in one field. I want to change (cATS) to (CATS), (dOGS) to (DOGS), and so on in this one field.

The following REPLACE query does not do the job.

UPDATE `TableTest` SET `Sub2` = REPLACE `Sub2`, '(c ', '(C')
WHERE `Sub2` LIKE '%(c%'

Can anyone give me the proper syntax? Thank you in advance for any replies.
 
why not use UCASE. i notice that all the results are in CAPS...

Known is handfull, Unknown is worldfull
 
another options:

ucase(substring(field_name,1,2))

Known is handfull, Unknown is worldfull
 
vbkris, thank you for the replies.

My example in the first post was not correct. The example in the first post should have read, "I want to change (cats) to (Cats), (dogs) to (Dogs), and so on in this one field."

I do not know how to integrate the ucase syntax into the MySql UPDATE syntax.

OK, using ucase, would the following syntax be correct?

UPDATE `TableTest` SET `Sub2` = REPLACE `Sub2`, ucase(substring(Sub2,(1))WHERE `Sub2` LIKE '%(c%'

UPDATE `TableTest` SET `Sub2` = REPLACE `Sub2`, ucase(substring(Sub2,(1))WHERE `Sub2` LIKE '%(d%'
 
something like this:

UPDATE `TableTest` SET `Sub2` = ucase(substring(Sub2,2))+substring(Sub2,3,length(Sub2)) WHERE `Sub2` LIKE '%(c%'

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top