Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B84839F9D5F for ; Mon, 20 Aug 2007 11:14:49 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 66479-03 for ; Mon, 20 Aug 2007 11:14:46 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from rv-out-0910.google.com (rv-out-0910.google.com [209.85.198.189]) by postgresql.org (Postfix) with ESMTP id 05E129F9D51 for ; Mon, 20 Aug 2007 11:14:46 -0300 (ADT) Received: by rv-out-0910.google.com with SMTP id l15so938741rvb for ; Mon, 20 Aug 2007 07:14:45 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=S+I1GVafbMBjKj4BkhN3VvPfIRgUB50YLymxES5Lk1gbNZ97u8K+KhWPURnZz6GFbDy3FdF91T4MpsL1Z/XcC51jjoRpPMenG0Z/mT6Rjyo7QnVG4IbqPgreTu0eLAMTw2NIapv0XZGHC1MQQY7956zEB8LfHo26U/VhJ8zfDKk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=o+9hid9S91+eZ4zD73Mw14CYt51KqIsLMaG276Lg7QE5tJKFr5/1qcgvnfHDpOaCh0L3aiy2H0Xd7xb6BDKlsvRcqmM5DVfwA/gn6jQCP947EWD6Z4BAzz4PfpShut62h16gkc4/sYNyWWVD81sXrFV50wiKplJj8t0DfIubKA4= Received: by 10.141.97.5 with SMTP id z5mr3280rvl.1187619285478; Mon, 20 Aug 2007 07:14:45 -0700 (PDT) Received: by 10.141.98.12 with HTTP; Mon, 20 Aug 2007 07:14:45 -0700 (PDT) Message-ID: Date: Mon, 20 Aug 2007 09:14:45 -0500 From: "Scott Marlowe" To: giuseppe.derossi@email.it Subject: Re: HELP, can't implement e filter Cc: pgsql-admin@postgresql.org In-Reply-To: <5721d54f0ab9128f6c815295a036b0f4@83.225.9.51> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <5721d54f0ab9128f6c815295a036b0f4@83.225.9.51> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/223 X-Sequence-Number: 26554 On 8/19/07, giuseppe.derossi@email.it wrote: > Hi, > I need to implement a filter in order to select from the first table the > second one... > it could be simple, but i'm wasting time. Please, is there anyone could help > me? > thanks in advance > Giu > > c1 c2 c3 c4 c5 > 1)133659;1;"0039";"00121";7 > 2)133664;1;"0039";"00121";12 > 3)133664;2;"0039";"00121";12 > 4)133665;2;"0039";"00121";12 > 5)135460;1;"0039";"01152"; > 6)135460;2;"0039";"01152"; > 7)135471;1;"0050";"00153";4 > 8)135471;2;"0050";"00153";4 > > > 1)133659;1;"0039";"00121";7 > 3)133664;2;"0039";"00121";12 > 4)133665;2;"0039";"00121";12 > 6)135460;2;"0039";"01152"; > 8)135471;2;"0050";"00153";4 Do you want the things in table1 that are in table2, or the things in table2 that are NOT in table2? Things in table1 that are in table2: select * from table1 join table2 on (table1.field1=table2.field1 and table1.field2=table2.field2 and ....) things in table1 that are not in table2: select * from table1 left join table2 on (table1.field1=table2.field2 and table1.field2=table2.field2 and ...) where table1.field1 IS NULL or table1.field2 IS NULL or ... replace elipses with the rest of the fields.