I have a table with three columns, description1, description2 & description3. In these columns I have various anchor tags linking to other articles on my site i.e.
This description talks about this item and has a <a href="/dir/item2.html">link</a> to other items on my site. It may go on to talk about another <a href="/dir/dir2/another-item-id-213.html">another item</a>. The amount of <a href="/another-item-id-214.html">links</a> can be more than one or none
I am in the process of changing the whole sites URL structure (a big gamble I know), and now wish to remove all the anchor tags from all the descriptions, so that there is no internal links in the columns. Is there a sql command that I can run that would complete this?
There's no way in MySQL to do this directly that I know of. So, probably the easiest way to do this would be to loop through the rows using PHP (or some other server side language), strip out the tags, and update the rows with the new value.
Using the strip_tags() [php.net] function in PHP could do the trick (you can whitelist any html tags you want to keep) or you can use preg_replace() [php.net] if strip_tags would remove more than you want it to.