I’m trying to run a query of the type “SELECT * FROM table WHERE id IN (1, 2, 3)” using a prepared statement. I tried a couple of ways to pass the list as a parameter, but it didn’t work: ERROR: syntax error at or near “$1”. I’m using PostgreSQL.
The only way that works so far is “SELECT * FROM table WHERE id IN (?, ?, ?)” with each value as a separate parameter. Is it possible to pass the list directly as a single parameter?
No, it’s not possible. You need to bind each parameter separately.