Try to search your question here, if you can't find : Ask Any Question Now ?

PostgreSQL multi-column WHERE = ANY(ARRAY)

HomeCategory: stackoverflowPostgreSQL multi-column WHERE = ANY(ARRAY)
pushpa asked 2 weeks ago

I have a table with three columns, “id”, “letter” and “number”. I have a list of pairs of “letter” and “number”, for which I need to get the “id”s in single query. Obviously, the easy solution is to use n queries, where n is the size of the list.

SELECT id FROM table WHERE number=... AND letter=...

But that requires n queries, in my case it is millions and there is large overhead. Previously, I only had a filter on list of “number”s, so I used

SELECT id FROM table WHERE number = ANY(ARRAY[...])

Is there some syntax that would do what I need, something like

SELECT id FROM table WHERE PAIR[letter,number] = ANY(ARRAY[PAIR[...],...])

Thank you.

1 Answers
Best Answer
Amit answered 2 weeks ago
Your Answer

3 + 16 =

Popular Tags

WP Facebook Auto Publish Powered By :