Binding multiple arrays for WHERE IN in PostgreSQL
- by Alec
So I want to prepare a query something like:
SELECT id FROM users WHERE (branch, cid) IN $1;
But I then need to bind a variable length list of arrays like (('a','b'),('c','d')) to it. How do I go about doing this? I've tried using ANY but can't seem to get the syntax right.
Cheers,
Alec
Edit:
After some fiddling around, this is valid syntactically:
SELECT id FROM users WHERE (branch, cid) = ANY ($1::text[][]);
and then binding the string '{{a,b},{c,d}}' to $1
but throws the error "operator does not exist: record = text". Changing 'text' to 'record' then throws "input of anonymous composite types is not implemented". Any ideas?