I'm trying to replace only certain parts of a string via an SQL query.
The column holds data formatted as so:
United States Postal Service <br> (Express Mail<sup>®</sup><br>---Approx. delivery time 07-Sep-2011):
I'm trying to make it export like so:
United States Postal Service (Express Mail---Approx. delivery time 07-Sep-2011):
To do this, I used CASE, like so:
SELECT
CASE ot.title
WHEN 'Free' THEN ''
WHEN ' <br>' THEN ' '
WHEN '<sup>®</sup> ' THEN ' '
WHEN '<br>---' THEN '---'
ELSE ot.title
END
FROM orders_total AS ot;
However, it won't work. I assume CASE only supports handling the entire string, not just a part of it.
Any ideas?
Peace, Chris
The REPLACE function solved the issue, working subquery here:
(SELECT REPLACE(REPLACE(REPLACE(REPLACE(ot.title, '(For orders of $75.00 or more with a maximum package weight of 50 lbs ):', ''), ' <br>', ' '), '<sup>®</sup>', ' '), '<br>', '') FROM orders_total AS ot WHERE ot.orders_id = o.orders_id AND ot.class = 'ot_shipping') AS orders_shipping_class