How to replace part of string in SQL(如何替换SQL中的部分字符串)

本文介绍了如何替换SQL中的部分字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在数据库列guid"中有 URL

i have URL in db column "guid"

http://example.com/wp-content/uploads/2014/03/Waterproofing2.png

我需要把它改成

http://example.com/blog/wp-content/uploads/2014/03/Waterproofing2.png

我需要用

http://example.com/wp-content/uploads/

http://example.com/blog/wp-content/uploads/

推荐答案

使用 替换 函数:

update `table` set `column`= replace (`column`, 'http://example.com/','http://example.com/blog/') where `column`like 'http://example.com/blog/wp-content/uploads%'

这篇关于如何替换SQL中的部分字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!