mysql和MSSQL字元替換函數

來源:互聯網
上載者:User

MSSQL替換語句:update 表名 set 欄位名=replace(cast(欄位名 as varchar(8000)),'abc.com','123.com')

例如:

 代碼如下 複製代碼
update PE_Article set Content=replace(cast(Content as varchar(8000)),'http://111cn.net/','http://www.111cn.net/')

其中PE_Article 為表名  Content為欄位名 http://111cn.net/為要替換的內容  http://www.111cn.net/為替換後的內容。

下面看mysql replace替換語句,其實也等

replace('www.mysql.com',   'w',   'ww'); 

replace(object,search,replace)
把object中出現search的全部替換為replace
select replace('www.163.com','w','Ww')--->WwWwWw.163.com
例:把表table中的name欄位中的aa替換為bb
update table set name=replace(name,'aa','bb')

 代碼如下 複製代碼

update `表名` set body=replace(body,'"upfile','"/upfile') WHERE body like '%src="upfile%' and cityid in(1176,1177,1178,1179,1181)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.