Possible Duplicate:
How to replace string in SQLite?
I have a table column data as
/var/abc/23423423/Documents/apple.jpg
/var/sdg/64444223/Documents/Banana.jpg
I want to update this column so that anything preceding /Documents is removed.
So output should be:
/Documents/apple.jpg
/Documents/Banana.jpg
How do I achieve this using UPDATE Statement of SQL?
Something like this will work:
INSTRlocates the position of the string/Documents/, andMIDgets everything beginning from there.Notes:
/Documents/Documents/in your path string.MIDandINSTRmay not be available, but most RDBMS support them.Updates:
After my reply you’ve updated that SQLite is the RDBMS of your choice – this makes things more difficult. There ain’t no INSTR in SQLite, so most people will advise you to parse the result with a program, change it there and update the data then – for example in this SO post.
However… since your two examples both have a fixed directory name length (in total 18 characters), there is the tiny chance that in your case you could do it slightly easier:
I haven’t tried this yet, but maybe this works for you.