Mysql选择第一封信 [英] Mysql Select first Letter

查看:53
本文介绍了Mysql选择第一封信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

M11111

M22222

M33333

M44444

M55555

<无线电通信/>


只是为了说清楚,这是我在mysql中的数据内容现在我的老板说他想把所有的第一个字母从M更改为X.我知道它很容易更新,但我的问题是,我只是在更新单词的第一个字母。

解决方案

更新的表名
组字段名= CONCAT( 'X',substring(fieldname,2))
where left(fieldname,1)='M'


尝试一些mySql字符串函数 - http://dev.mysql.com/doc/refman/5.0/en/string -functions.html [ ^ ]。

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.

解决方案

Update tablename
Set fieldname=concat('X', substring(fieldname,2))
where left(fieldname,1)='M'


Try out some mySql string functions - http://dev.mysql.com/doc/refman/5.0/en/string-functions.html[^].


这篇关于Mysql选择第一封信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆