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

WBOY
Release: 2016-06-13 12:20:07
Original
1233 people have browsed it

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

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

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

------解决思路----------------------
使用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 />
Copy after login


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template