1.字符串大小写转化:
(1).将tbl_student表的user_name字段所有小写字母,替换为大写:
update tbl_student set user_name=UPPER(user_name);
(2).将tbl_student表的user_name字段所有大写字母,替换成小写:
update tbl_student set user_name=LOWER(user_name);
2.清除字符串首尾空格,或者指定字符:
(1).清除tbl_student表的user_name字段首尾空格
update tbl_student set user_name=TRIM(‘ ‘ from user_name);
(2).清除字符串首部指定字符A:
update tbl_student set user_name=TRIM(LEADING ‘A‘ from user_name);
(3).清除字符串尾部指定字符B
update tbl_student set user_name=trim(TRAILING ‘B‘ from user_name);
3.替换字符串:
(1).替换字符串中的数字1为字母I
update tbl_student set user_name=replace(user_name,‘1‘,‘I‘);
4.用正则(REGEXP):
(1).若结尾两个为字母,则去掉
update tbl_student stu stu.user_name=substring(stu.user_name,LENGTH(stu.user_name)-2) where stu.user_name REGEXP ‘[a-zA-Z]{2,}$‘;
时间: 2024-10-03 22:29:16