Re: How to find entries missing in 2nd table?

From: "Milen A(dot) Radev" <milen(at)radev(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to find entries missing in 2nd table?
Date: 2006-07-11 16:57:20
Message-ID: 44B3D870.1090409@radev.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Broersma Jr написа:
>> Hi,
>> I realize I probably lost my marbles but I've been having a god
>> awful time with a single query:
>>
>> control:
>> ....
>> ....
>> controller_id pk;
>>
>>
>> datapack:
>>
>> controller_id fk;
>> ....
>> ....
>> ....
>>
>> I need to get all entries from the table control that are not listed in
>> datapack.
>
> SELECT C.CONTROLLER_ID
>
> FROM CONTROL AS C
> LEFT JOIN DATAPACK AS D ON ( C.CONTROLLER_ID = D.CONTROLLER_ID)
>
> WHERE D.CONTROLLER_ID IS NULL;
>

Or
(SELECT controller_id FROM control)
EXCEPT
(SELECT controller_id FROM datapack)
?

--
Milen A. Radev

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma Jr 2006-07-11 17:03:39 Re: How to find entries missing in 2nd table?
Previous Message Frank Bax 2006-07-11 16:04:45 Re: How to find entries missing in 2nd table?