mysql phpmyadmin 替换包含问号的字符串

标签 mysql replace

用新网址替换旧网址问题带问号

我尝试使用以下命令:

UPDATE `kiss_texte` SET `kt_txt` = replace(kt_txt, 'xxx://www.hotelpronto.com/?affiliateid=30606\', 'xxx://stohler.ch/promo/liste-promotion.php?local=fr');

error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxx://stohler.ch/promo/liste-promotion.php?local=fr')' at line 1

UPDATE `kiss_texte` SET kt_txt = REPLACE(kt_txt, 'xxx://www.hotelpronto.com/?affiliateid=30606\', 'xxx://stohler.ch/promo/liste-promotion.php?local=fr') WHERE `kt_txt` LIKE 'http://www.hotelpronto.com/?aff ttttttttiliateid=30606\';

error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'xxx://stohler.ch/promo/liste-promotion.php?local=fr') WHERE `kt_txt` LIKE 'http' at line 1

问号似乎没有被解释为文本

最佳答案

为什么要使用前面的 \ 转义单引号 '

UPDATE `kiss_texte` SET `kt_txt` = replace(kt_txt, 'xxx://www.hotelpronto.com/?affiliateid=30606', 'xxx://stohler.ch/promo/liste-promotion.php?local=fr');

如果您仍然需要尾部反斜杠,那么您必须使用双斜杠进行转义,例如 \\

关于mysql phpmyadmin 替换包含问号的字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57079896/

相关文章:

MySql 错误 1064 - 恢复数据库

php - 获取关系型 mysql 表中的外部 id

c# - 替换字符串中的某个子字符串 - .Replace() 方法对我不起作用 C#

JavaScript 查找字符串中正则表达式的每个实例并将其替换为不同的值

php - 将逗号分隔的文本从输入中插入到数据库中,而没有重复的条目

mysql - "TableB"中 "LEFT JOIN TableB ON TableA.name = TableB.name"的任何值?

php - while 循环打印额外的空行

linux - 批量搜索并替换文件路径

JavaScript RegExp #hasgtag 替换为 html 中没有超哈希链接的链接

regex - 在 Sublime Text 2 中搜索数字并对其进行一些数学评估