mysql 技巧
2015-09-11 19:47
459 查看
在一次导入数据过程中 由于导入数据过多,同步没有控制很好。导致产生了1000多条脏数据,这些脏数据的订单编号产生了相同,一条一条改是不现实的,方法最好是用一句sql解决 然后mysql居然提供了操作字符串的功能,不得不佩服实在是太强大了。
后来询问了下同学,居然提供了另外一种方法。
先说自己的
UPDATE customer SET customer_code=REPLACE(customer_code ,'20150911145','20150911185')
这条批量操作是没有where 条件语句的
同学提供的
Update table set customer_code = '20150910'||substring(customer_code,8,长度) where customer_code like '20150911%'
这种感觉太爽了
后来询问了下同学,居然提供了另外一种方法。
先说自己的
UPDATE customer SET customer_code=REPLACE(customer_code ,'20150911145','20150911185')
这条批量操作是没有where 条件语句的
同学提供的
Update table set customer_code = '20150910'||substring(customer_code,8,长度) where customer_code like '20150911%'
这种感觉太爽了
相关文章推荐
- MySQL中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复