Hello everybody.
Let's say I have an array with strings that are values of rows that I need to pull from DB. Let's say the array is:
searchStringArray = {'qwe', 'rty', 'asd',' fgh', 'zxc'}
I can construct my WHERE statement in my query in a pretty simple way:
"WHERE
t1.column1 IN (' " || Concat Items(searchStringsArray, " ', ' ")|| " ' )"
which when parsed would give me the following string:
"WHERE
t1.column1 IN('qwe', 'rty', 'asd', 'fgh', 'zxc')"
But what if my searchStringArray has not full strings but partial strings?
I need to simplify my script. Currently I have a query that has multiple Contains statements, which in SQL looks like this:
"WHERE
(t1.column1 LIKE '%qwe%') OR
(t1.column1 LIKE '%rty%') OR
(t1.column1 LIKE '%asd%') OR
(t1.column1 LIKE '%fgh%') OR
(t1.column1 LIKE '%zxc%')"
This is pretty cumbersome to construct from a string array. I was wondering if I can write an equivalent WHERE statement that looks something like this:
"WHERE
t1.column1 IN ('%qwe%', '%rty%', '%asd%', '%fgh%', '%zxc%')"
or something like this:
"WHERE
t1.column1 MATCH('%qwe%' OR '%rty%' OR '%asd%' OR '%fgh%' OR '%zxc%')"
or something similar that would be easier to construct using Concat Items()
. I tried two examples above, although they seem to be valid SQLite syntax, they do not work in JSL. Any suggestions?
Thanks,
M