Global search and replace text in posts Syntax Error

Avatar
  • Answered
I've done this before. I thought I had the correct code, but I keep getting this error. I'm trying to replace a right arrow ">" without the quotes. Here's what I'm getting now: SQL query:

UPDATE wp_posts SET post_content = REPLACE(post_content,'>',''); MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '

UPDATE wp_posts SET post_content = REPLACE(post_content,'>' at line 1 Thanks for your help.

Avatar
johnpaulb-imhs1
Hello winjama,

Thank you for getting back to us. Since your SQL syntax looks correct, it should return a message stating how many rows were altered.

You may have to check a specific row to see if anything changed.

Also, where/how are you running the SQL query? From PHPMyAdmin?

If you have any further questions, feel free to post them below.

Thank you,
John-Paul
Avatar
johnpaulb-imhs1
Hello winjama,

Thank you for your question about search and replace in SQL. I immediately noticed you have the following in your statement and error:
<p class="code_block">

This "p" tag is HTML code, and should not be part of your SQL query. It is used for formatting code in a paragraph.

If you have any further questions, feel free to post them below.

Thank you,
John-Paul