X-Original-To: pgsql-sql-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 9B46A9FA4A8 for ; Tue, 11 Jul 2006 13:57:34 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87164-03 for ; Tue, 11 Jul 2006 13:57:29 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id AE25F9F9316 for ; Tue, 11 Jul 2006 13:57:29 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1G0LY5-0008Vm-7J for pgsql-sql@postgresql.org; Tue, 11 Jul 2006 18:57:25 +0200 Received: from pirus.securax.be ([213.16.46.130]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Jul 2006 18:57:25 +0200 Received: from milen by pirus.securax.be with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 11 Jul 2006 18:57:25 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-sql@postgresql.org From: "Milen A. Radev" Subject: Re: How to find entries missing in 2nd table? Date: Tue, 11 Jul 2006 19:57:20 +0300 Lines: 38 Message-ID: <44B3D870.1090409@radev.net> References: <20060711141951.GA17936@s2.yuriev.com> <20060711155201.22418.qmail@web31810.mail.mud.yahoo.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: pirus.securax.be User-Agent: Mozilla Thunderbird 1.5.0.4 (Windows/20060516) In-Reply-To: <20060711155201.22418.qmail@web31810.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/182 X-Sequence-Number: 25756 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