Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3455076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:34:10+00:00 2026-05-18T09:34:10+00:00

We have a database that has a bunch of records with some bad data

  • 0

We have a database that has a bunch of records with some bad data in one column, in which an embedded editor escaped some stuff that shouldn’t have been escaped and it’s breaking generated links.

I want to run a query to replace the bad characters in all the records, but can’t figure out how to do it. I found the replace() function in MySQL, but how can I use it inside a query?

For example, what would be the correct syntax if I wanted to replace the string &lt; with an actual less-than angle bracket (<) in all records that have &lt; in the articleItem column? Can it be done in a single query (i.e. select and replace all in one swoop), or do I have to do multiple queries? Even if it’s multiple queries, how do I use replace() to do the replace on the value of a field on more than one record?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:34:11+00:00Added an answer on May 18, 2026 at 9:34 am

    At a very generic level

    UPDATE MyTable
    
    SET StringColumn = REPLACE (StringColumn, 'SearchForThis', 'ReplaceWithThis')
    
    WHERE SomeOtherColumn LIKE '%PATTERN%'
    

    In your case you say these were escaped but since you don’t specify how they were escaped, let’s say they were escaped to GREATERTHAN

    UPDATE MyTable
    
    SET StringColumn = REPLACE (StringColumn, 'GREATERTHAN', '>')
    
    WHERE articleItem LIKE '%GREATERTHAN%'
    

    Since your query is actually going to be working inside the string, your WHERE clause doing its pattern matching is unlikely to improve any performance – it is actually going to generate more work for the server. Unless you have another WHERE clause member that is going to make this query perform better, you can simply do an update like this:

    UPDATE MyTable
    SET StringColumn = REPLACE (StringColumn, 'GREATERTHAN', '>')
    

    You can also nest multiple REPLACE calls

    UPDATE MyTable
    SET StringColumn = REPLACE (REPLACE (StringColumn, 'GREATERTHAN', '>'), 'LESSTHAN', '<')
    

    You can also do this when you select the data (as opposed to when you save it).

    So instead of :

    SELECT MyURLString From MyTable

    You could do

    SELECT REPLACE (MyURLString, 'GREATERTHAN', '>') as MyURLString From MyTable

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a huge database that has several tables that hold several million records.
So, I have this code that grabs a bunch of data from the database,
I have a table in a sql server 2008 database that contains bunch of
I have a table that has about 1/2 million records in it. Each month
I'm not sure what's wrong with the following setup. I have a View that
I have a bunch of jQuery Ajax calls on my WordPress website. After making
I have an interface: public abstract class Authorizer<T> where T : RequiresAuthorization { public
I have the following situation: A user will define a certain filter on a
I didn't find much in tutorials on this specific question.. So I have a
Background I am working on a legacy small-business automation system (inventory, sales, procurement, etc.)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.