This is an old article on nostuff.org. It is (a) out of date (b) with broken inages and links (c) badly written. I, Chris Keene, disown all of it, even though it was created by me. See the main nostuff.org homepage, or the About page for more info.
SQL update: doing a find/replace on part of a field
By chriskeene |
SQL is one of those things I rarely use, and it’s normally the simple stuff, but doing anything a little more complex can be non-obvious. For example, I had a bunch of URLs where I just need to update a part of the URL, as we were moving some files on a website. I eventually found what I wanted within the comments to the MySQL UPDATE command documentation. (credit to Alex de Landgraaf on July 21 2004):
UPDATE xoops_bb_posts_text
SET post_text=(
REPLACE (post_text,
‘morphix.sourceforge.net’,
‘www.morphix.org’));
UPDATE table
SET fieldname=(
REPLACE (fieldname,
‘/somedir/images/’,
‘/newhome/graphics/’));
Does the trick nicely on MySQL :)
You have been reading a really old article on nostuff.org which probably is (a) out of date (b) with broken inages and links (c) badly written. I, Chris Keene, disown all of it, even though it was created by me. See the main nostuff.org homepage, or the About page for more info.