Re: How to find entries missing in 2nd table? - Mailing list pgsql-sql

From Milen A. Radev
Subject Re: How to find entries missing in 2nd table?
Date
Msg-id 44B3D870.1090409@radev.net
Whole thread Raw
In response to Re: How to find entries missing in 2nd table?  (Richard Broersma Jr <rabroersma@yahoo.com>)
List 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



pgsql-sql by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: How to find entries missing in 2nd table?
Next
From: Bryce Nesbitt
Date:
Subject: Re: Can function results be used in WHERE?