mysql如何截取字符串某一个位字符并替换改字符

mysql如何截取字符串某一个位字符并替换改字符

例如先查询改字段所有首位还有T字符的数据

SELECT     substring(number,1,1) from ko_order where number LIKE 'T%'

 

再把‘T’替换成z

SELECT REPLACE ( substring(number,1,1), 'T', 'z' )  from ko_order where number LIKE 'T%'

和原来的字符串在合并

 

SELECT CONCAT(REPLACE ( substring(number,1,1), 'T', 'z' ),substring(number,2)) from ko_order where number LIKE 'T%'

 

方法随便写的,后面在优化!

留下回复