Received: from racerx.cabrion.com (racerx.cabrion.com [166.82.231.4]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0J4XT052481 for ; Thu, 18 Jan 2001 23:33:29 -0500 (EST) (envelope-from rob@cabrion.com) Received: from cabrionhome (gso163-25-153.triad.rr.com [24.163.25.153]) by racerx.cabrion.com (8.8.7/8.8.7) with SMTP id XAA06737; Thu, 18 Jan 2001 23:34:09 -0500 Message-ID: <002201c081d1$8f402eb0$4100fd0a@cabrion.org> From: "rob" To: "Diehl, Jeffrey" , References: Subject: Re: Help with query. (*) Date: Thu, 18 Jan 2001 23:37:40 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4133.2400 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 X-Archive-Number: 200101/886 X-Sequence-Number: 3110 Read the docs on "exists" that should be what you are looking for. --rob ----- Original Message ----- From: "Diehl, Jeffrey" To: ; Cc: "Diehl, Jeffrey" Sent: Tuesday, January 16, 2001 3:42 PM Subject: Help with query. (*) > I'm having difficulty writing a query which I really can't live without... > > I need to get a list of records from table A for which there are > corresponding records in table B. I've tried to use the intersect clause, > but it doesn't seem to work, or it runs far too long. For example: > > select * from A > where 1=1 > intersect select * from A where > B.x=A.x > and A.y=B.y > and A.z=B.z > limit 100 > > I need the most efficient method possible; my A tables have upward of 5 > Million records. The B table, btw, only has about 100 records. > > > Any help will be most appreciated. > >