Mysql – Replace special character

MySQLreplacesyntaxupdate

I am trying to replace the character ' with the character ", using:

UPDATE posts SET text = replace(text, ''', '"');

but:

1 errors were found during analysis.
Ending quote ' was expected. (near "" at position 59)

Best Answer

MySQL accepts ' and " interchangeably. So use ' to quote " and " to quote ':

REPLACE(text, "'", '"')

(There are many other solutions, involving hex, conversions, etc, but the above seems simple and straightforward.)

But... The error message does not look like a MySQL error, so I suspect your query is in a quoted string in your client language. So...

What client language? Does it use backslash (\) for escaping things?