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)
Avatarpushpa asked 5 months 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
AvatarAmit answered 5 months ago
Your Answer

13 + 13 =

Popular Tags

WP Facebook Auto Publish Powered By :