1

I have a videos table with a column URL with many different URL types

https://google.com/questions/ask?963
https://google.com/embed/ask
https://google.com/top/123.html
https://video.net/embed-ask?963
https://video.net/embed-123.html
https://video.net/top?123.html

I need to delete part of a specific URL (delete embed-) from

https://video.net/embed-75mdabvgl3do.html

to

https://video.net/75mdabvgl3do.html

I have tray this SQL but return an empty result (0 rows affected)

UPDATE `videos` SET url = REPLACE(url, '%video.net/embed-%', '%video.net/%') WHERE `url` LIKE '%video.net/embed-%';
0

1 Answer 1

3

You could try this:

UPDATE videos
SET url = REPLACE(url, 'video.net/embed-', 'video.net/')
WHERE url LIKE '%video.net/embed-%';

This hopefully would be specific enough of a replacement. If not, we could consider using regular expressions (available if using MySQL 8+).

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

1 Comment

Perfect solution

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.