Reputation: 9219
I have a value in a table row as given below:
/mnt/sdcard/Tutorialtwo/chapter_1b.png
I want to update the table so that it changes the above to this:
/storage/sdcard1/Tutorialtwo/chapter_1b.png
How do I do this in SQLite?
Upvotes: 0
Views: 38
Reputation: 434635
You could use substr
substr(X,Y,Z), substr(X,Y)
Thesubstr(X,Y,Z)
function returns a substring of input stringX
that begins with theY
-th character and which isZ
characters long. IfZ
is omitted thensubstr(X,Y)
returns all characters through the end of the stringX
beginning with theY
-th.
to extract the '/Tutorialtwo/chapter_1b.png'
suffix and then a string concatenation to put the new '/storage/sdcard1'
prefix on. The SQL version would look something like this:
update t
set c = '/storage/sdcard1' || substr(c, 12)
where ...
where t
is the table name and c
is the column in question.
Upvotes: 2