需要搜索和替换图像路径

时间:2011-04-21 15:10:58

标签: mysql

我正在尝试更新SQL数据库中的图像路径。我尝试了以下但是没有用:

UPDATE `wp_posts` 
SET `post_content` = replace(`post_content`,'%src="http://www.theworldeffect.com/.a/%"%','src="http://www.domainname.com/timages/%.jpg"')

2 个答案:

答案 0 :(得分:0)

试试这个

update TABLE_NAME set FIELD_NAME = replace(FIELD_NAME, ‘find this string’, ‘replace found string with this string’);

http://www.mydigitallife.info/how-to-find-and-replace-text-in-mysql-database-using-sql/

答案 1 :(得分:0)

replace()不会为你做正则表达式匹配。您只能使用它将另一个静态字符串替换为给定字符串,例如

replace(`post_content`, 'src="http://www.theworldeffect.com/.a/',
                        'src="http://www.domainname.com/timages/')

这只会替换前缀,但这对您来说已经足够了。

相关问题