Re: table unions

From: "Sean Davis" <sdavis2(at)mail(dot)nih(dot)gov>
To: "Wright, George" <George(dot)Wright(at)infimatic(dot)com>
Cc: pgsql <pgsql-novice(at)postgresql(dot)org>
Subject: Re: table unions
Date: 2008-08-08 15:49:58
Message-ID: 264855a00808080849h7f960d5cw3d1a1e57e5881377@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Fri, Aug 8, 2008 at 11:13 AM, Wright, George
<George(dot)Wright(at)infimatic(dot)com> wrote:
> Novice question:
>
> How can I apply conditional logic when doing a union of two tables?
>
> TableA TableB
> ------ ------
> value1 value2 value1 value2
> 1 10 5 15
> 11 20
>
> SELECT * FROM TableA UNION SELECT * FROM TableB;
> returns:
>
> value1 value2
> 1 10
> 5 15
> 11 20
>
>
> what I want is
>
> value1 value2
> 1 5
> 5 15
> 15 20
>
> The tables are huge and already in ascending order.

Hi, George.

What conditional logic are you trying to apply? Union will simply
take the rows from the two tables and combine them.

Sean

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Wright, George 2008-08-08 15:59:40 Re: table unions
Previous Message Wright, George 2008-08-08 15:13:34 table unions