涉及“http://”时的Mysql搜索和替换

时间:2013-05-24 03:30:16

标签: mysql

我试图在MYSQL中搜索和替换但是收到错误。因为#" http://"

,我要这样做。

任何人在尝试更换此类东西时都有任何建议吗?

输入的代码:

update movies_news set select_page = replace(select_page, ‘http://movie’, ‘http://www.movie’);

但它会引发以下错误:

#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 '://movie’, ‘http://www.movie’)' at line 1   

1 个答案:

答案 0 :(得分:2)

发布以便可以接受:

update movies_news set select_page = replace(select_page, ‘http://movie’, ‘http://www.movie’);

包含智能引号,这些引号不会被解释为普通单引号,因此会出现语法错误。它应该是

update movies_news set select_page = replace(select_page, 'http://movie', 'http://www.movie');

一般情况下,要非常小心地将代码复制到“智能”文本编辑器(Microsoft Word等)中