我有一个 user_lists 表,其中包含 integer[] 类型的 user_list 列。
我正在尝试执行此查询,这看起来很基本:
select id, alias from users where id = ANY(select user_list from user_lists where id = 2 limit 1);
它给出了这个错误:
错误:运算符不存在:integer = integer[]
提示:没有运算符匹配给定的名称和参数类型。您可能需要添加显式类型转换。
我正在使用 postgres 8.3.11。升级不是一种选择。
我错过了什么?
最佳答案
试试这个:
select id, alias from users
where (select user_list from user_lists where id = 2 limit 1)
@> ARRAY[id];
关于arrays - postgresql:任何子查询返回数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10650145/