Home  >  Article  >  Backend Development  >  怎么批量替换某一字段的数据前缀

怎么批量替换某一字段的数据前缀

WBOY
WBOYOriginal
2016-06-13 12:20:071186browse

如何批量替换某一字段的数据前缀?
我现在文件名都是绝对路径。
我想把文件名改成相对路径,但是数据很多,一个个改很麻烦,有没有办法批量替换。

<br />原文件名:http://www.baidu.com/upload/1422.jpg<br />改成这样:/upload/1422.jpg<br />

------解决思路----------------------
update tbl_name set 路径=replace(路径, 'http://www.baidu.com/', '/')

------解决思路----------------------
使用mysql replace可实现

比如你要将表 tb1里面的 f1字段的abc替换为def 
UPDATE tb1 SET f1=REPLACE(f1, 'abc', 'def'); 

<br />update `tablename` set field_name=replace(`field_name`, 'http://www.baidu.com/', '');<br />


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn