X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1D30D329DFC for ; Fri, 8 Oct 2004 06:34:44 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 85534-04 for ; Fri, 8 Oct 2004 05:34:39 +0000 (GMT) Received: from rock.spider.ru (rock.spider.ru [62.183.34.226]) by svr1.postgresql.org (Postfix) with ESMTP id 3530E329D3E for ; Fri, 8 Oct 2004 06:34:39 +0100 (BST) Received: from rock (localhost [127.0.0.1]) by rock (Postfix) with SMTP id 69BD72B34A; Fri, 8 Oct 2004 09:34:36 +0400 (MSD) Received: from sad.localnet.ru (sad.localnet.ru [10.0.0.72]) by rock.spider.ru (Postfix) with ESMTP id F3E772B341; Fri, 8 Oct 2004 09:34:34 +0400 (MSD) Content-Type: text/plain; charset="iso-8859-1" From: sad Organization: IT To: Thomas F.O'Connell , mmurrain@dbdes.com Subject: Re: help on a query Date: Fri, 8 Oct 2004 08:44:23 +0400 User-Agent: KMail/1.4.3 Cc: pgsql-sql@postgresql.org References: <4166036B.1020001@murrain.net> <9E089E3A-18D7-11D9-936A-000D93AE0944@sitening.com> In-Reply-To: <9E089E3A-18D7-11D9-936A-000D93AE0944@sitening.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200410080844.23298.sad@bankir.ru> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.3 tagged_above=0.0 required=5.0 tests=UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200410/47 X-Sequence-Number: 19150 On Friday 08 October 2004 07:10, Thomas F.O'Connell wrote: > A query that should get the job done is: > > SELECT registration_id > FROM registrations r > WHERE NOT EXISTS ( > SELECT 1 > FROM receipts > WHERE registration_id =3D r.registration_id > ); Don't, PLEASE, don't !!! drive this way : SELECT r.registration_id FROM registrations AS r LEFT OUTER JOIN receipts AS rec ON rec.registration_id =3D r.registration_id WHERE rec.registration_id IS NULL;