From: Ross J. Reedstrom <reedstrm@rice.edu>
To: Andrew Perrin <clists@perrin.socsci.unc.edu>
Cc: Bruno Wolff III <bruno@wolff.to>
Cc: Tim Lynch <admin+pgsqladmin@thirdage.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: OT: seeking query help, where?
Date: Fri, 17 Jan 2003 09:54:50 -0600
Message-ID: <20030117155450.GB15778@wallace.ece.rice.edu> (raw)
In-Reply-To: <Pine.LNX.4.21.0301171004580.16506-100000@perrin.socsci.unc.edu>
References: <20030117151203.GA1798@wolff.to>
<Pine.LNX.4.21.0301171004580.16506-100000@perrin.socsci.unc.edu>
On Fri, 17 Jan 2003, Bruno Wolff III wrote:
> On Fri, Jan 17, 2003 at 08:57:14 -0500,
> Andrew Perrin <clists@perrin.socsci.unc.edu> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: reedstrm@rice.edu, clists@perrin.socsci.unc.edu, bruno@wolff.to, admin+pgsqladmin@thirdage.com
Subject: Re: OT: seeking query help, where?
In-Reply-To: <20030117155450.GB15778@wallace.ece.rice.edu>
References: <20030117151203.GA1798@wolff.to> <Pine.LNX.4.21.0301171004580.16506-100000@perrin.socsci.unc.edu> <20030117155450.GB15778@wallace.ece.rice.edu>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox