sql 搜索和替换SQL

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 搜索和替换SQL相关的知识,希望对你有一定的参考价值。

SET @table_name = '';
SET @column_name = '';
SET @searched_string = "";
SET @replace_with = "";

SET @s = CONCAT('UPDATE ', @table_name, ' SET ', @column_name, '= REPLACE(`', @column_name, '`, \'', @searched_string, '\', \'', @replace_with, '\') WHERE `', @column_name, '` LIKE CONCAT(\'%', @searched_string, '%\')');

PREPARE stmt1 FROM @s;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;

以上是关于sql 搜索和替换SQL的主要内容,如果未能解决你的问题,请参考以下文章