当前位置: 移动技术网 > IT编程>数据库>Mysql > SQL去除空格、截取数据的方法:trim、substring

SQL去除空格、截取数据的方法:trim、substring

2018年09月29日  | 移动技术网IT编程  | 我要评论

1、如device表中的identity字段正常的字段长度时32位,但是某些不正常的数据,后面多出空格,需要去掉的话,执行以下命令:

1 select * from device where length(identity)=33;
2 update device set identity=trim(identity) where length(identity)=33;

2、截取某字段的的某些位数的方法,如截取identity第21位之后的数据,并保存位identity12字段:

1 update device set identity12=substring(identity,21);

 

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网