I have a custom type in Postgres:
CREATE TYPE child AS
(id integer,
name text,
surname text,
age integer);
and table
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)
)
and I want to get parents which have a child who has a name = "John"
I tried something like that:
select id, name
from parent
where 'John' = any (select (unnest(childs)).name from parent)
but I received all parents. I would be so grateful when someone solve my problem.