How to pass list of ids to query.
List<Long> ids;
...
client.preparedQuery("SELECT id, name FROM features WHERE id IN $1").execute(Tuple.of(ids))
When I passed this query an error occurred saying invalid syntax near IN
How to pass list of ids to query.
List<Long> ids;
...
client.preparedQuery("SELECT id, name FROM features WHERE id IN $1").execute(Tuple.of(ids))
When I passed this query an error occurred saying invalid syntax near IN
You have to use the ANY
operator:
client.preparedQuery("SELECT id, name FROM fruits WHERE id = ANY($1)")
.execute(Tuple.of(ids.toArray(new Long[ids.size()])));
With IN
operator one has to specify each parameter, with the ANY
you can pass an array.