Re: OT: seeking query help, where?

From: Andrew Perrin <clists(at)perrin(dot)socsci(dot)unc(dot)edu>
To: Tim Lynch <admin+pgsqladmin(at)thirdage(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: OT: seeking query help, where?
Date: 2003-01-17 13:57:14
Message-ID: Pine.LNX.4.21.0301170856130.14045-100000@perrin.socsci.unc.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

I'd suggest something similar to, but slightly different from, what others
have:

SELECT DISTINCT email FROM (SELECT email FROM table_1 UNION SELECT
email FROM table_2) AS combined;

that way you avoid duplicates across tables.

----------------------------------------------------------------------
Andrew J Perrin - http://www.unc.edu/~aperrin
Assistant Professor of Sociology, U of North Carolina, Chapel Hill
clists(at)perrin(dot)socsci(dot)unc(dot)edu * andrew_perrin (at) unc.edu

On Thu, 16 Jan 2003, Tim Lynch wrote:

> First, sorry for the OT, flame me off-list!
>
> I'm a sysadmin being impressed into dba service. i've been getting along
> pretty well writing queries and making reports, but i've got some questions.
> suggestions for a good list/forum for help?
>
> from two tables both with email_addr columns, i want a distinct list of all
> email_addrs in one column. what i do now is select distinct on each and then
> sort -u the results.
>
> thanks in advance
> -t
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Andrew Perrin 2003-01-17 15:05:07 Re: OT: seeking query help, where?
Previous Message Nigel J. Andrews 2003-01-17 12:04:06 Re: Do Something before Abort on Trigger ???