kjarsenal kjarsenal - 6 months ago 25
MySQL Question

find and replace data in multiple records

I have a mysql 5 database table with a longtext field that permits html code (via markdown) to be entered as data. Unfortunately, I made a minor copy/paste error that I didn't catch until I had more that 200 records. Because it's the same error on each record


as opposed to


it would be easier if there were some sql I could write that would allow me to find "href:" on all records and replace with "href=" in the same transaction, than if I have to edit each record individually. Is there anything I can do or am I just screwed?


You can do this:

UPDATE Data_Table 
SET Html_Column = REPLACE(Html_Column, 'href:', 'href=');