I have a table in mySQL and want to update a specific column holding a directory. The directory structure should be extended and the corresponding columns should be updated with a subdirectory. There are many rows to update so I look for a convenient script to do.
Example:
column c1 holds directory
/startpoint/dir_a/
/startpoint/dir_a/subdir_1/
/startpoint/dir_a/subdir_1/subsubdir_1/
/startpoint/dir_a/subdir_1/subsubdir_2/
/startpoint/dir_a/subdir_1/subsubdir_3/
/startpoint/dir_a/subdir_2/
/startpoint/dir_a/subdir_3/
So I need to move directories followed from startpoint to startpoint/system.
This should be in after script:
/startpoint/system/dir_a/
/startpoint/system/dir_a/subdir_1/
/startpoint/system/dir_a/subdir_1/subsubdir_1/
/startpoint/system/dir_a/subdir_1/subsubdir_2/
/startpoint/system/dir_a/subdir_1/subsubdir_3/
/startpoint/system/dir_a/subdir_2/
/startpoint/system/dir_a/subdir_3/
My (maybe silly) update didn't work as expected:
update table1 set dir=/startpoint/system/||substr(dir,12) where dir like '/startpoint/dir_a/%'
So any idea from expert to do this with a more specific sql update ?
Thanks.
dir