【SQL】替换某个字段中的某个值

情况说明

数据库中的数据存储情况:在下面的 *Imgs 字段,为如下情况:

<img width='100%' src='http://192.168.0.*/image/productIntroImgs/1.jpg'></img><img width='100%' src='http://192.168.0.*/image/productIntroImgs/2.jpg'></img><img width='100%' src='http://192.168.0.*/image/productIntroImgs/3.jpg'></img>

需求

需要更改该字段中的 192.168.0.* —> ...:8080
所以需要以下的语句:

update t_product as a set a.IntroImgs =REPLACE (a.IntroImgs,'192.168.0.*','*.*.*.*:8080');
update t_product as a set a.ParaImgs =REPLACE (a.tParaImgs,'192.168.0.*','*.*.*.*:8080');

改正后

<img width='100%' src='http://*.*.*.*:8080/image/productIntroImgs/1.jpg'></img><img width='100%' src='http://*.*.*.*:8080/image/productIntroImgs/2.jpg'></img><img width='100%' src='http://*.*.*.*:8080/image/productIntroImgs/3.jpg'></img>

猜你喜欢

转载自blog.csdn.net/qq_29750461/article/details/124036115