【发布时间】:2017-04-13 21:27:40
【问题描述】:
我在 Postgres 中有一个自定义类型:
CREATE TYPE child AS
(id integer,
name text,
surname text,
age integer);
和表
CREATE TABLE parent
(
id integer NOT NULL,
name text NOT NULL,
surname text NOT NULL,
age integer NOT NULL,
childs child[],
CONSTRAINT parent_pkey PRIMARY KEY (id)
)
我希望父母有一个名字为“约翰”的孩子
我尝试过类似的方法:
select id, name
from parent
where 'John' = any (select (unnest(childs)).name from parent)
但我接待了所有的父母。 如果有人解决了我的问题,我将不胜感激。
【问题讨论】:
标签: arrays database postgresql