Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 如何在where查询中使用postgres数组?_Sql_Postgresql_Postgresql 9.5 - Fatal编程技术网

Sql 如何在where查询中使用postgres数组?

Sql 如何在where查询中使用postgres数组?,sql,postgresql,postgresql-9.5,Sql,Postgresql,Postgresql 9.5,postgreSQL中的一个表有一列数据类型为text[] TableA: id uuid tableb_ids text[] TableB: id uuid name text 现在我需要编写一个查询,如下所示: select * from tableB where id in (select tableb_ids from tableA where id ="xxxx-xxxx-xxxx-xxxx")

postgreSQL中的一个表有一列数据类型为text[]

TableA:
id              uuid
tableb_ids      text[]

TableB:
id              uuid
name            text
现在我需要编写一个查询,如下所示:

select * from tableB where id in (select tableb_ids from tableA where id ="xxxx-xxxx-xxxx-xxxx")
我无法更改架构/表定义。
i、 e我不能为表A中表B的每个条目保留多个条目。TableA是一个复杂的表。

要在一个表中查找记录ID包含在其他表的数组中的记录,可以在这些表上进行联接:

选择b* 来自表b 内联接表 在b.id::TEXT=ANYa.tableb_id上 和a.id='xxxxxxxxxxxxxxxx' 另一种方法是:

选择b* 来自表b 我在哪里 选择UNNESTa.tableb\u id 从表a 其中a.id='xxxx xxxx xxxx' x -不确定子查询中是否需要别名
类似于从tableb b中选择b.*在b.id=ANYa.tableb上加入tablea_ids@404我得到错误:运算符不存在:uuid=text[]当我尝试该方法时b.id::text=ANYa.tableb_ids@Surya:一旦您对初始问题有了答案,请不要扩展您的问题。改为问一个新问题。@404:你应该加上这个问题作为答案,这样它就可以被接受,并且这个问题可以被标记为已解决