I have a column in my SQLite database that contains a file path. Given a portion of the file path, I need to return all the next folders. I would also like to return whether the next portion is the last path in the string (or does not end in a ‘/’). So if I have the folders:
/my/folder/one
/my/folder/two
/my/folder/path/three
/another/path
/one/two/three
And I have the path:
/my/folder/
The result would return something along the lines of:
+----------+------+
| isLast | item |
+----------+------+
| 1 | one |
| 1 | two |
| 0 | path |
+----------+------+
I’ve been struggling with this for a while so if anyone can provide any guidance it would be greatly appreciated.
This query:
will give you a result like this:
Removing the subpath requires the
instr()function, which was only recently introduced in SQLite 3.7.15: