Replace text with spaces in MySQL
Posted
by
javipas
on Server Fault
See other posts from Server Fault
or by javipas
Published on 2011-01-22T19:14:28Z
Indexed on
2011/02/27
7:26 UTC
Read the original article
Hit count: 565
I'm trying to do a global replace of search in my database, which has a lot of articles with a double carriage return because of this code:
<p> </p>
I'd like to replace this in my WordPress blog so instead of that appears... nothing, and so I can delete the CR. I've tried this on my database
UPDATE wp_posts set post_content = replace (post_content,'<p> </p>','');
but didn't work. Why? Do I have to add special thinks to consider the space between the <p>
and the</p>
?
Mmm. Good points, both Jon Angliss and Wim. Jon, as you could have guessed, the database shows no entries with that text string. So there's something going on inside the post_content field.
Wim, the famous was replaced previously, but there are still hundreds of posts that for some reason have something different between the p and the /p tags.
I've done a search of one of the posts with this error:
mysql> select * from wp_posts where post_title like '%3DVisionLive%';
And looking in the wp_content field, this is a little piece of the post:
Phil Eisler, responsable de la divisi?n 3D Vision.?</p>
<p>?</p>
<p>Este portal ser? por tanto
No spanish tilde (accent) shown on the terminal, and instead of an space there's a quotation mark between the p and the /p tags. I've tried to replace <p>?</p>
, but again, no results. There's some character (or several) there, but I don't know how to discover that. Maybe it's the character set of my terminal, but I've accessed the database from phpmyadmin and in that case there's a space character between the p and the /p. Weird.
© Server Fault or respective owner