Click here to Skip to main content
15,891,372 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
M11111
M22222
M33333
M44444
M55555


just to make clear, this is the content of my data in mysql now my boss said that he wants to change all the first letter from M to X. I know its easy to update but my problem is im only updating the first letters of the word.
Posted
Updated 30-Jan-14 18:04pm
v2

Update tablename
Set fieldname=concat('X', substring(fieldname,2))
where left(fieldname,1)='M'
 
Share this answer
 
v7
Comments
Crixalis Paul 30-Jan-14 23:40pm    
Your code only show the data but i want to update it
Peter Leow 30-Jan-14 23:50pm    
Added.
Peter Leow 31-Jan-14 1:02am    
Finally got your requirement clear. See solution 1.
Peter Leow 5-Feb-14 7:29am    
Did my solution help? If so, do remember to accept it as solution and vote.
Try out some mySql string functions - http://dev.mysql.com/doc/refman/5.0/en/string-functions.html[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900