0

I have just imported a database table from a previous site, and one of the table headers has a title of 'enclosure' and in this, there is a big list of URLs, all starting http://richardgordoncook.com/dl/audio/filename.mp3 etc.

I need to change the start of this URL from richardgordoncook.com to richgc.com but I don't know how to be that specific with a query.

I can easily change one:

UPDATE `db141188_cnc`.`wp_StreamPad_Tracks` SET `enclosure` = 'http://richgc.com/dl/audio/andy_summers.mp3',
`sourceUrl` = 'http://www.curatorialnoiseclub.com' WHERE `wp_StreamPad_Tracks`.`id` =5 LIMIT 1 ;

But I don't want to write each one out.

So, I need to change richardgordoncook.com to richgc.com.

Is there any way to do this?

2 Answers 2

3

Something like this:

update <table> 
SET enclosure = replace(enclosure, 'richardgordoncook.com', 'richgc.com')
Sign up to request clarification or add additional context in comments.

Comments

0
UPDATE TableX   
  CROSS JOIN
    ( SELECT 'http://richardgordoncook.com'  AS original
           , 'http://richgc.com'             AS replacement
    ) AS c
SET enclosure 
    = CONCAT( replacement
            , RIGHT(enclosure, LEN(enclosure) - LEN(original))
            )
WHERE enclosure LIKE CONCAT(original, '%')

Comments

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.