Skip to content
Advertisement

postgresql search column with integer[] with another array

I am trying to figure out a way that I can search a column containing an array of integers. For example, column a -> [1,2]. Using another array, ex: b -> [1,2,3]

If all the values in a are in the array b, I want to return that result.

I’ve tried using unnest and = ANY but to no avail. Does anyone else have a solution to this?

Advertisement

Answer

You can use the “contains” operator @>

array[1,2,3] @> array[1,2]
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement