2011-04-21 38 views
0

我想更新我的SQL數據庫中的圖像路徑。我嘗試以下,但它沒有工作:需要搜索並替換圖像路徑

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

回答

0

試試這個

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

替換()你不會做的正則表達式匹配。您只能使用它替換給定的字符串與另一個靜態字符串,例如

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

這隻會替換前綴,但這可能已足夠。