Tom
Tom

Reputation: 927

Replace \' with '

I had trouble with Magic Quotes before. Now that I've got that fixed, I unfortunately have hundreds of entries already in my database with \' instead of just an apostrophe.

This statement doesn't work:

UPDATE timeline SET tweet = Replace(tweet,"\'","'")

How can I replace all the \' with just '? Or maybe I could just replace \ with nothing?

Upvotes: 0

Views: 92

Answers (1)

Scott
Scott

Reputation: 298

You need to escape the \ in your UPDATE statement, so change it to this:

UPDATE timeline SET tweet = Replace(tweet,'\\','')

or

UPDATE timeline SET tweet = Replace(tweet,'\\\'','\'')

SQL Fiddle: http://sqlfiddle.com/#!2/d74e9/2

Upvotes: 3

Related Questions