简体   繁体   中英

MYSQL + Change path + Update substring

I have a question, i have table 'file' with a column 'path' in my DB called Pics. Each path is like "C:\\my folder\\pics\\pic1.jpg" etc.......

How i do to change:

C:\my folder\pics\

to

C:\my NEW folder\NEW pics\

I try a select for the path folder without the filename like this :

SELECT substring(c1,1,locate(substring_index(c1,'/',-1),c1)-1) FROM t1

that give me "C:\\my folder\\pics\\". Now i need to update all the column path. What is the correct query. I try this but dont work.

update foto set path = 'z' where path = (SELECT substring(path,1,locate(substring_index(path,'\\',-1),path)-1)) 

Thanks for sharing

完成。

update foto set path = REPLACE(path,(SELECT substring(path,1,locate(substring_index(path,'\\',-2),path)-1)),'" & TextBox2.Text & "'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM