今天正好遇到一個SQL小問題,特做備注
在原有的表中數據如pic
在不動原內容的基礎上增加../路徑,但不能修改原數據值
原數據

SQL: pic字段 需要增加'../'的內容
update Bmps_Wxs set htwx_pic='../'+htwx_pic where htwx_rq between '2013-12-25' and '2014-01-12'
增加后效果

一不小心多按一下修改語句,我暈,N多數據多增加了../
update Bmps_Wxs set htwx_pic='../'+htwx_pic where htwx_rq between '2013-12-25' and '2014-01-12'

這該去除吧,看了一下數據好幾萬條全改了,我暈
表字段名 表以前內容 替換后內容
update Bmps_Wxs set htwx_pic=replace(htwx_pic,'../../','../')
修改后:

REPLACE用法介紹
REPLACE ( original-string, search-string, replace-string )
參數
如果有某個參數為 NULL,此函數返回 NULL。
original-string 被搜索的字符串。可為任意長度。
search-string 要搜索並被 replace-string 替換的字符串。該字符串的長度不應超過 255 個字節。如果 search-string 是空字符串,則按原樣返回原始字符串。
replace-string 該字符串用於替換 search-string。可為任意長度。如果 replacement-string 是空字符串,則刪除出現的所有 search-string。
