Mark Kelly wrote:
> If I have two queries:
> SELECT pub_id as id, email FROM publication WHERE email_accepted = TRUE;
> 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.
Sean Davis wrote:
> Take a look at sql UNION--this is not postgresql specific.
Thomas Kellerer wrote:
> More precisely: UNION ALL to avoid the redundant step that tries to eliminate
One may eliminate the redundant test of a truth value against a truth value.
SELECT pub_id as id, email FROM publication WHERE email_accepted
SELECT contact_id as id, email FROM person WHERE email_accepted ;
One trusts that the result columns in the two tables have compatible types.
I am curious how you interpret the "id" result in that query.
Honi soit qui mal y pense.
In response to
pgsql-novice by date
|Next:||From: Mark Kelly||Date: 2011-02-21 00:31:52|
|Subject: Re: Combining queries|
|Previous:||From: Jean-Yves F. Barbier||Date: 2011-02-20 02:52:28|