Morteza
Morteza

Reputation: 2153

MySQL REPLACE doesn't work

I use this to replace \" with " :

UPDATE wp_posts SET post_content = REPLACE (post_content, '\"', '"')

That query returns 0 row(s) affected and nothing happens.

What is wrong this this query?

Upvotes: 2

Views: 2147

Answers (3)

faq
faq

Reputation: 3076

use:

REPLACE(`post_content`, '\\"', '"')

Upvotes: 1

jakobandersen
jakobandersen

Reputation: 1409

The backslash charecter is escape character in MySQL so you need to escape it itself like this:

UPDATE wp_posts SET post_content = REPLACE(post_content, '\\"', '"')

Upvotes: 1

bobwienholt
bobwienholt

Reputation: 17610

You need to escape your backslash:

UPDATE wp_posts SET post_content = REPLACE (post_content, '\\"', '"')

Upvotes: 5

Related Questions