Re: Combining queries - Mailing list pgsql-novice

From Thomas Kellerer
Subject Re: Combining queries
Date
Msg-id ijoq8p$dd1$2@dough.gmane.org
Whole thread Raw
In response to Re: Combining queries  (Sean Davis <sdavis2@mail.nih.gov>)
Responses Re: Combining queries
Re: Combining queries
List pgsql-novice
Sean Davis wrote on 19.02.2011 14:47:
>
>
> On Sat, Feb 19, 2011 at 8:25 AM, Mark Kelly <pgsql@wastedtimes.net <mailto:pgsql@wastedtimes.net>> wrote:
>
>     Hi.
>
>     If I have two queries:
>
>     SELECT pub_id as id, email FROM publication WHERE email_accepted = TRUE;
>
>     and
>
>     SELECT contact_id as id, email FROM person WHERE email_accepted = TRUE;
>
>     is there any way I could combine these into a single query? I'd like to be
>     able to create a view of all email-able entities in the system.
>
>
> Hi, Mark.
>
> Take a look at sql UNION--this is not postgresql specific.
>
More precisely: UNION ALL to avoid the redundant step that tries to eliminate duplicates

Regards
Thomas

pgsql-novice by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: Updating a table field with a consecutive number
Next
From: Mark Kelly
Date:
Subject: Re: Combining queries