开发者

Mysql replace() function, help with query (what chars do I escape?)

I am trying to update an old cms where images were stored in /images/editor/, they开发者_如何学Go are now stored in a bucket on amazon s3. I'm trying to update the database using mysql replace. I've done this in the past with replacing simple words, but now Mysql is reporting an error, I suspect because this is more than a simple word:

UPDATE contents SET desc = replace(desc, 
'/images/editor/', 
'http://s3.amazonaws.com/my_bucket/editor/')

Do I need to escape the : or slashes? I've tried escaping it with a '\' to no avail. Can someone get me pointed in the right direction? Thanks!

Edit

Here's the error I am getting, nothing too telling

error : 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 'desc = replace(desc, '/images/editor', 'http://s3.amazonaws.com/app_navigator/ed' at line 1


nothing to do with the escape (ie. nothing need to be escaped),
but you need to quote the reserved keyword desc

so,

UPDATE contents SET `desc` = replace(`desc`, ...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜