0

I have a table called: k01cv_sh404sef_urls Inside this table we have the following rows:

id, cpt, rank, oldurl, newurl and dateadd

The row "oldurl" contains entry's such as:

English/network
English/hardware-and-software
corporate-social-responsibility

I'd like to have a query that removes the English/ part from all the items in the "oldurl" row so that the english/network would be just network, English/hardware-and-software would be hardware-and-software, etc.

The result would be that the row "oldurl" contains entry's such as:

network
hardware-and-software
corporate-social-responsibility

2 Answers 2

1

Can you get away with something as simple as this?

UPDATE table SET oldurl = REPLACE(oldurl, 'English/', '');

(please test using a SELECT before running it on the real data!)

Sign up to request clarification or add additional context in comments.

Comments

1
UPDATE k01cv_sh404sef_urls
SET    oldurl = SUBSTRING(oldurl FROM 9)
WHERE  oldurl LIKE 'English/%'

This will not just read/attempt to update only matching records (which will yield a particular performance benefit if your table is large but has an index in which oldurl is the leftmost column), but will also only strip the 'English/' that appears at the very start of the string.

1 Comment

Thanks, that works perfectly. I also have some url's like nl/nederlands/hardware-en-software Where I want to remove the /nederlands/ part. How can I accomplish this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.