Re: [sqlite] Finding second occurrence of character in string

2014-10-26 Thread Stephen Chrzanowski
Another method beyond what was suggested above/below would be that since the / could be considered a delimiter, you could consider each field a word and insert each word into a separate table and index each word. Have another table reference the indexed word to match whatever table you've

Re: [sqlite] Finding second occurrence of character in string

2014-10-26 Thread James K. Lowden
On Sun, 26 Oct 2014 15:27:24 +0300 Baruch Burstein wrote: > I need to get the path with the > first 2 parts stripped off. Currently I am doing: > > substr(path, 4+instr(substr(path,4),'/')) > > But that seems long and probably inefficient. > What is the

Re: [sqlite] Finding second occurrence of character in string

2014-10-26 Thread Stadin, Benjamin
Sorry, this should rather be something like sqlite3_mprintf("%q", "Path-_1/path%2/path3_³); https://www.sqlite.org/c3ref/mprintf.html Am 26.10.14 14:57 schrieb "Stadin, Benjamin" unter : >char *zSQL = sqlite3_mprintf("Path-_1/path%2/path3_", zText); >

Re: [sqlite] Finding second occurrence of character in string

2014-10-26 Thread Stadin, Benjamin
Hi, One possible way could be to combine this with FTS4 (with parenthesis support enabled) and a LIKE clause: SELECT substr(path, 4+instr(substr(path,4),'/‚)) as relativepath FROM table WHERE table MATCH "path:ab AND path:cd“ AND path LIKE "ab/cd%“ How it works: - The match clause efficiently

Re: [sqlite] Finding second occurrence of character in string

2014-10-26 Thread Andrea Peri
Hi, I don't know if the SQLite SQL function are coming from a sql specs standard. I guess however that a better usable string function for manage paths is one function that retrieve the last occurrence of a string. Because very often the need is to extract the last part of a filepath. my 2ct,

[sqlite] Finding second occurrence of character in string

2014-10-26 Thread Baruch Burstein
Hi! I have a column which represents a file path: ab/cd/gf ab/qw/ert ab/fgrd/ert ab/foo/bar/fgr ab/bar/foo/foobar/etc ab/etc/d etc... I happen to know in my case that the first part of the path is a certain fixed string ('ab' in the above example). I need to get the path with the first 2 parts