如何在此表中的所有 *.jpg 地址前后添加一些字符:
id value type
1 a.jpg photo
2 b text
3 c.jpg photo
这是我想要的结果:
id value type
1 [img]http://www.b.com/a.jpg[/img] photo
2 b text
3 [img]http://www.b.com/c.jpg[/img] photo
最佳答案
我倾向于这样做:
update t
set value = replace('[img]http://www.b.com/{0}[/img]', '{0}', value)
where value like '%.jpg';
我喜欢用replace()
来构造字符串,因为这样更容易查看和修改字符串的格式。
关于mysql - 向mysql中的特定行添加额外字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42509191/