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 0119E9FB1DC for ; Wed, 12 Jul 2006 05:08:03 -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 70727-04 for ; Wed, 12 Jul 2006 05:07:52 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from Absolut.his.de (absolut.his.de [192.124.237.1]) by postgresql.org (Postfix) with SMTP id 4BEBF9FB202 for ; Wed, 12 Jul 2006 05:07:52 -0300 (ADT) Received: from 10.1.0.74 by Absolut.his.de (InterScan E-Mail VirusWall NT); Wed, 12 Jul 2006 10:06:55 +0200 content-class: urn:content-classes:message Subject: Re: How to find entries missing in 2nd table? MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Date: Wed, 12 Jul 2006 10:06:34 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.0.6603.0 Message-ID: <507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [SQL] How to find entries missing in 2nd table? Thread-Index: AcalIP115bV03AqlTpSh5Ooy5KiHVgAaL1WA From: "Exner, Peter" To: "Richard Broersma Jr" , "SQL Postgresql List" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200607/188 X-Sequence-Number: 25762 Hi,=20 what about SELECT controller_id FROM control WHERE controller_id NOT IN (SELECT DISTINCT controller_id FROM datapack); ? Regards Peter > -----Urspr=FCngliche Nachricht----- > Von: pgsql-sql-owner@postgresql.org=20 > [mailto:pgsql-sql-owner@postgresql.org] Im Auftrag von=20 > Richard Broersma Jr > Gesendet: Dienstag, 11. Juli 2006 19:04 > An: SQL Postgresql List > Betreff: Re: [SQL] How to find entries missing in 2nd table? >=20 >=20 >=20 > --- Richard Broersma Jr wrote: >=20 > > > >> I need to get all entries from the table control that are not=20 > > > >> listed in datapack. > > > >=20 > > > > SELECT C.CONTROLLER_ID > > > >=20 > > > > FROM CONTROL AS C=20 > > > > LEFT JOIN DATAPACK AS D ON ( C.CONTROLLER_ID =3D=20 > D.CONTROLLER_ID) > > > >=20 > > > > WHERE D.CONTROLLER_ID IS NULL; > > > >=20 > > >=20 > > >=20 > > > Or > > > (SELECT controller_id FROM control) > > > EXCEPT > >=20 > > Good point! But don't forget to include the list. :-) > >=20 > > Regards, > >=20 > > Richard Broersma Jr. > > > (SELECT controller_id FROM datapack) ? > > >=20 > > > -- > > > Milen A. Radev > > >=20 > >=20 > >=20 >=20 >=20 > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 9: In versions below 8.0, the planner will ignore your desire to > choose an index scan if your joining column's datatypes do not > match >=20