Hello list,

I have a rather simple parent/child structure, but I don't know how to
formulate my problem in SQL.

Question:
I want to know all those parent.id values where there are at least two
children with the same X value.
Put differently:
Get me all the parents whose children do not have pairwise disjoint X
values.


SQL:
create table parent ( id number );
alter table parent add constraint parent_pk primary key (id);
create table child ( x number, parent_fk number );
alter table child add constraint FK foreign key (parent_fk) references
parent(id);


Some data:
insert into parent values (1);
insert into parent values (2);

insert into child values (10,1);
insert into child values (20,1);
insert into child values (20,1);

insert into child values (100,2);
insert into child values (200,2);


Expected response:
1, because of the two 20 entries.


Any ideas appreciated.

Regards,
Matthias



-- 
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to