且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在MySQL中将字符串添加到列值之前?

更新时间:2021-08-14 08:41:10

您可以使用

You can use the CONCAT function to do that:

UPDATE tbl SET col=CONCAT('test',col);

如果您想变得更聪明,并且只更新尚未预先进行测试的列,请尝试

If you want to get cleverer and only update columns which don't already have test prepended, try

UPDATE tbl SET col=CONCAT('test',col)
WHERE col NOT LIKE 'test%';