Nev
Nev

Reputation: 25

replace directory path to url path in mysql database table

Dear all..before i give up after multiple trial and error attempts,can someone please help me with below query.

I am trying to replace the path name D:\Downloads\Music\ (note the slash) to http://mysite.com/Music/ in mysql field name called "filename" under "songlist" table.

Below is the query code that I tried ,but nothing happens.It only gives me the following message : 0 row(s) affected. ( Query took 0.1428 sec )

UPDATE songlist SET filename = replace(filename, "D:\Downloads\Music", "http://mysite.com/Music/")

many thanks for the help!!!

Upvotes: 0

Views: 2373

Answers (1)

Jason McCreary
Jason McCreary

Reputation: 73011

You need to escape the slashes. Check out the following as an example:

-- with escaping, yay it works
SELECT REPLACE(filename, 'D:\\Downloads\\Music', 'http://mysite.com/Music/') FROM songlist;

Upvotes: 1

Related Questions