MySQL为某字段加前缀、后缀

在开发过程中,可能会遇到加前缀或者后缀的情况。比如为视频添加路径时,如果手动加起来肯定慢,而且比较不符合程序员的特点,我们就应该能让程序跑就不会手动加。

使用UPDATE sql 语句:update vod set path=concat('hello',path,'world') where id>0;

vod是数据表名,path是你要更改的字段名,hello是要加的前缀,world是要加的后缀。

如果只想加前缀便写成.... path=concat('hello',path) ....同理后缀一样。

猜你喜欢

转载自www.cnblogs.com/dlmg/p/11403507.html