如何通过sql替换数据库中的撇号

时间:2015-05-16 12:43:53

标签: mysql

我正在尝试将"?t"字符串替换为"'t"(撇号)

我在phpMyAdmin中输入此命令

UPDATE "myTable"
SET "myColumn" = REPLACE ("myColumn", "\?t", "\'t")

How can I use mySQL replace() to replace strings in multiple records?

中所述

我收到此错误

#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 #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 UPDATE "myTable"
SET "myColumn" = REPLACE ("myColumn", "\?t", "\'t") at line 1

我的命令出了什么问题?

由于

1 个答案:

答案 0 :(得分:1)

不要引用表名或列名。如果你需要逃脱它们,请使用反引号

UPDATE `myTable`
SET `myColumn` = REPLACE (`myColumn`, '?t', '\'t')