I am trying to use an IN statement in a WHERE clause in the Query Library.
I've written the query and am testing in the Query Library interface where you can enter the variables on the right hand side.
The query in principle looks like
SELECT * FROM TABLE WHERE id IN({{ ids }}
I have confirmed as pure SQL that the ids I am entering do return results.
Initially I tried putting the ids as an actual array in the variable
e.g. ["0058d000001aRaSAAU","0058d000006YPY7AAO"]
Query Library recognises this as an array but produces an empty result. Using the button to view the output SQL I can see it is missing the single quotes needed.
So then I tried to map the data to add the quotes back in
SELECT * FROM TABLE WHERE id IN({{ ids.map((x) => `"${x}"`) }})
Frustratingly this produces the correct SQL but still doesn't work.
I've also tried just using the correct string as the variable e.g.
'0058d000001aRaSAAU','0058d000006YPY7AAO'
This also produces the correct SQL but does not return any results.
Not had any luck using integers either.
Anybody figured out how to use an IN statement with a variable?