替换MariaDB中包含方括号和引号实体的文本

I am trying to run a query in MariaDB 10.3 that will replace [google]" with [google] in SMF:

UPDATE smf_messages SET body = REPLACE(body, '[google]"', '[google]') WHERE ID_BOARD = 64

这个查询对我来说适用于普通文本,但是现在它给了我

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''[google]&quot)' at line 1

评论
傻瓜Ina
傻瓜Ina

如果我理解正确,那么您正在寻找转义字符

UPDATE smf_messages SET body = REPLACE(body, '\'[google]"', '\'[google]') WHERE ID_BOARD = 64

这将在方括号前寻找一个单引号,您需要简单地在要转义的字符之前添加\

点赞
评论