Re: SQL query question - Mailing list pgsql-general

From Tomasz Myrta
Subject Re: SQL query question
Date
Msg-id 41C978E8.1020002@klaster.net
Whole thread Raw
In response to SQL query question  ("Joost Kraaijeveld" <J.Kraaijeveld@Askesis.nl>)
List pgsql-general
> Hi all,
>
> I have 2 tables, with a 1-n relation:
>
> parent( oid, parent_name)
> child(oid, child_name, iod_parent)
>
> How do I get the parent_names of all parents without a child?

select parent_name from parent
  left join child on (parent.oid=child.iod_parent)
where child.oid is null;

or

select parent_name from parent
where not exists (select * from child where
  child.iod_parent=parent.oid);

Regards,
Tomasz Myrta

pgsql-general by date:

Previous
From: "vinita bansal"
Date:
Subject: default index created for primary key
Next
From: Együd Csaba
Date:
Subject: Strange Index behavior