简体   繁体   English

postgresql 搜索列与 integer[] 与另一个数组

[英]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].例如,列 a -> [1,2]。 Using another array, ex: b -> [1,2,3]使用另一个数组,例如:b -> [1,2,3]

If all the values in a are in the array b, I want to return that result.如果 a 中的所有值都在数组 b 中,我想返回该结果。

I've tried using unnest and = ANY but to no avail.我试过使用 unnest 和 = ANY 但无济于事。 Does anyone else have a solution to this?有没有其他人对此有解决方案?

您可以使用“包含”运算符@>

array[1,2,3] @> array[1,2]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM