sql - instr() function SQLITE for Android? -
i wanna following on existing sqlite database on android kind built colomns: id --- rule --- path --- someotherdata
a rule e.g. contains part of filename (either trivial stuff "mypicture" or filetype "jpg"). want is, want write query, gets rules, contain part of inputstring. have tried following example: string value = "somepicturefilename.jpg"
my statement:
"select distinct * " + table_rules + " instr('"+ value + "',rule)!=0 order " + key_id+ " desc;"
the statement in java "value" should inserted in statement.
however, not work. not familiar sql nor sqlite, have tip= ;) thanks.
edit: i've tried charindex, didn't work either.
edit: more detailed example. following database given.
id --- rule --- 1 "jpg" 2 "ponies" 3 "gif" 4 "pdf"
now user enters filename. let's "poniesasunicorns.jpg". "poniesasunicorns.jpg" input string , query should match both id#1 , id#2 because "poniesasunicorns.jpg" contains both "jpg" , "ponies"
i hope clarifies want.
edit: here tried too:
string statement = "select distinct * " + table_rules + " charindex(rule,'" + value + "') > 0 order " + key_id + " desc;";
but throws "no such operation" exception.
afaik instr()
not available, can use:
select * table replace("poniesasunicorns.jpg", rule, "") != "poniesasunicorns.jpg";
or case insensitive matches:
select * table replace(upper("poniesasunicorns.jpg"), upper(rule), "") != upper("poniesasunicorns.jpg");
Comments
Post a Comment