10/01/2013

SQL: How to REPLACE a String of Characters in a Database Column or Field

I moved some old articles into a WordPress database.

But there were some formatting problems, mostly due to incompatible character codes.

For example, there were non-breaking spaces from Windows that had been used as paragraph indents.

I didn't want them there at all, so I used this code to replace all of the characters using SQL.

wp_posts is the table where Blog Posts are stored.
post_content is the columns where the body of Posts are stored.
"Â Â Â Â  " represents the oddball character translation that I had to replace.
UPDATE wp_posts
SET post_content =
REPLACE (post_content, "Â Â Â Â  ", "")
WHERE post_content LIKE "%Â Â Â Â  %";

No comments :

Post a Comment