Jump to content

Recommended Posts

How to Search Records in Table and Replace Characters?

Hi,

Thank you Very Much for your help!

How do I search records in a table for specific quote character and replace it with a different quote character.
(Windows / Website Compatible Font?)

I know the basic SQL commands;

SELECT * FROM `table` WHERE `body` ... blah blah blah,

But how do I search inside the text record for:


 
and replace them with this:

"

AND




replace with:

"


AND



replace with:


'

?

Thank You VERY MUCH for Your Help!

:D

FirstBorn

 

The function you're looking for happens to be called REPLACE(). So do an UPDATE query and chain as many REPLACE() calls as you need:

UPDATE
  some_table
SET
  some_column = REPLACE(REPLACE(REPLACE(some_column, '...', '...'), '...', '...'), '...', '...')
;

I hope you're not doing this regularly?

I hope you're not doing this regularly?

 

In other words, find the code that inserts those records and do the replacements on the text before the data is inserted. Once the problem has been fixed at the source, you can then run the necessary REPLACE queries to resolve the existing data.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.