Skip to content
Advertisement

How to query all rows where a given column matches at least all the values in a given array with PostgreSQL?

The request below:

returns a list like this:

How to get the ids for which id must have at least a and b, and more generally the content of a given array ?

From the example above, I would get:

Advertisement

Answer

For two values, you can use windowing boolean aggregation:

A more generic approach uses array aggregation:

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement