I had an interesting problem today where I needed to update strings in a database table field based on a certain criteria.
A bad character had gotten into the URL field in the rhpRef table. The SQL updates and string that matches ‘warehouse-’ with ‘warehouse’. Ive added the where clause just to ensure only the correct rows are updated.
Here’s the code for future reference:
UPDATE rhpRef SET url = replace(url, 'warehouse-', 'warehouse') WHERE url LIKE '%warehouse-%';
Hope it might help someone else.
Advertisement
18 January, 2011 at 12:01 pm |
thanks for shared