I have a function that returns an Array of 1-5 integers, each time the array length is different:
[5, 10, 45, 55, 64]
How would I generate a SQL query based on the length of that array?
Example: if the array is 3 integers long I would need a query such as
Array: [10, 25, 30]
SELECT * FROM comments WHERE id IN($1, $2, $3)
if the array is 5 integers long I would need:
Array: [5, 9, 20, 41, 35]
SELECT * FROM comments WHERE id IN($1, $2, $3, &4, &5)