0
我想更新我的SQL數據庫中的圖像路徑。我嘗試以下,但它沒有工作:需要搜索並替換圖像路徑
UPDATE `wp_posts`
SET `post_content` = replace(`post_content`,'%src="http://www.theworldeffect.com/.a/%"%','src="http://www.domainname.com/timages/%.jpg"')
我想更新我的SQL數據庫中的圖像路徑。我嘗試以下,但它沒有工作:需要搜索並替換圖像路徑
UPDATE `wp_posts`
SET `post_content` = replace(`post_content`,'%src="http://www.theworldeffect.com/.a/%"%','src="http://www.domainname.com/timages/%.jpg"')
試試這個
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/')
這隻會替換前綴,但這可能已足夠。
不確定這是否有幫助,不要認爲您可以使用%作爲通配符。你可以不用? – gmadd 2011-04-21 15:26:47