IN Operator - Custom Query - Integer values

Hello everyone!

In my server action, I have an array like this:

["123", "134", "567", "767"]

I need to use these values within a custom query, using IN operator.
The problem is that the values of the array are string and the field I’m using the IN operator is an integer field.

Any tips on how to use an array as a parameter, converting its values to int using IN operator?
:slight_smile:

Thanks!

It might be helpful to look at this thread.

1 Like

hey @TomD! Thanks!!

I sorted out using postgres operator ANY:

:P2 is the array…ANY operator is to use with arrays, so, no need to convert values!
Hope it helps someone in the same situation I was :smiley:

2 Likes

Thanks @otavionestares for this clear picture. I’d never got the ANY operator to work with variables in custom queries before… this little bit of syntax has sorted the issue.

1 Like