How do I use a JS array from a SQL query result in a second query's WHERE IN clause?

I have a working SQL query Cases and want to use part of that query result Cases.data.id (an array of integers) in a WHERE IN clause in a subsequent query. I've tried manipulating the JS array into different forms with JSON.stringify(), join() etc. but I'm not having any luck.

Here's what I have:

I realise this is probably very straightforward but for whatever reason the solution escapes me!

Thanks in advance :smile:

2 Likes

Try doing {{formatDataAsArray(Cases.data.id)}}

Thank you for the suggestion, but no joy. I think that's really to transform columnar SQL query results into arrays. Cases.data.id is already an array.

OK didn't know - have you tried using = ANY({{Cases.data.id}}) instead of IN

3 Likes

We're in business! Thank you, I never thought to try ANY