Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id C9848475FED for ; Fri, 17 Jan 2003 10:54:49 -0500 (EST) Received: from ece.rice.edu (ece.rice.edu [128.42.4.34]) by postgresql.org (Postfix) with ESMTP id 57A7F475E91 for ; Fri, 17 Jan 2003 10:54:49 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with SMTP id B629E68AAD; Fri, 17 Jan 2003 09:54:53 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by ece.rice.edu (Postfix) with ESMTP id CA91D68A6F; Fri, 17 Jan 2003 09:54:52 -0600 (CST) Received: from wallace.ece.rice.edu (wallace.ece.rice.edu [128.42.12.154]) by ece.rice.edu (Postfix) with ESMTP id 3F96468A5B; Fri, 17 Jan 2003 09:54:51 -0600 (CST) Received: from reedstrm by wallace.ece.rice.edu with local (Exim 3.36 #1 (Debian)) id 18ZYpW-0004E4-00; Fri, 17 Jan 2003 09:54:50 -0600 Date: Fri, 17 Jan 2003 09:54:50 -0600 From: "Ross J. Reedstrom" To: Andrew Perrin Cc: Bruno Wolff III , Tim Lynch , pgsql-admin@postgresql.org Subject: Re: OT: seeking query help, where? Message-ID: <20030117155450.GB15778@wallace.ece.rice.edu> Mail-Followup-To: "Ross J. Reedstrom" , Andrew Perrin , Bruno Wolff III , Tim Lynch , pgsql-admin@postgresql.org References: <20030117151203.GA1798@wolff.to> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-Virus-Scanned: by AMaViS snapshot-20020300 X-DCC--Metrics: ece.rice.edu 1066; Body=1 Fuz1=1 Fuz2=1 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200301/193 X-Sequence-Number: 7035 On Fri, 17 Jan 2003, Bruno Wolff III wrote: > On Fri, Jan 17, 2003 at 08:57:14 -0500, > Andrew Perrin wrote: > > > > that way you avoid duplicates across tables. > > The union operator already removes duplicates. Right, which means everyone's UNION queries have too many DISTINCTs in them: SELECT email from table1 UNION SELECT email from table2 ; should do it. Here's proof: note the duplicate 'foo' and 'bar': test=# select * from table1; email ----------------- foo@example.com bar@example.com bar@example.com (3 rows) test=# select * from table2; email ------------------ quux@example.com foo@example.com (2 rows) test=# select email test=# select email from table1 union select email from table2; email ------------------ bar@example.com foo@example.com quux@example.com (3 rows) Ross -- Ross Reedstrom, Ph.D. reedstrm@rice.edu Research Scientist phone: 713-348-6166 The Connexions Project http://cnx./rice.edu fax: 713-348-6182 Rice University MS-39 Houston, TX 77005