mysql数据库字段内容替换案例

客户oa升级,由低版本升级到高版本,数据库结构彻底不一样,须要作数据迁移;
html

迁移后不知道什么缘由致使html正文新闻中的图片没法显示,检查确认:mysql

<img alt='' src='/seeyon/fileUpload.do?method=showRTE&fileId=141971704706210626&createDateA6=2014-12-28&type=image' border='0' complete='complete'/><br>
<img alt='' src='/seeyon/fileUpload.do?method=showRTE&fileId=141971709556210626&createDateA6=2014-12-28&type=image' border='0' complete='complete'/>

如上,数据库字段存储内容图片地址,其中id,时间都是可变参数,问题是时间错误致使图片没法显示;正则表达式

须要把createDateA6=2014-12-28 参数去掉便可;sql

解决方法:数据库

一、用 mysql数据库replace函数替换,问题replace不支持正则表达式匹配,如何替换?   查后放弃:(函数

二、用substr字符串截取,,理论上是能够的,可是有多个图片,查询字符串位置须要设置开始点,比较麻烦 ,数据库性能也有问题,折腾了一会放弃:(性能

变换思路:unix

       只要后台获取不到这个参数值就能够了,其实不必删除,只要更名便可,replace就行:code

       解决sql:htm

update news_body set content=replace(content,'&createDate=','&createDateA6=') where unix_timestamp(create_date)<unix_timestamp('2010-11-11') and content like '%/seeyon/fileUpload.do?method=showRTE&fileId=%';

相关文章
相关标签/搜索