Skip site navigation (1) Skip section navigation (2)

table unions

From: "Wright, George" <George(dot)Wright(at)infimatic(dot)com>
To: "pgsql" <pgsql-novice(at)postgresql(dot)org>
Subject: table unions
Date: 2008-08-08 15:13:34
Message-ID: 51548D6D5BEB57468163194A8C1A0E980161A35B@MAGPTCPEXC02.na.mag-ias.net (view raw or flat)
Thread:
Lists: pgsql-novice
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.


In response to

Responses

pgsql-novice by date

Next:From: Sean DavisDate: 2008-08-08 15:49:58
Subject: Re: table unions
Previous:From: Peter JacksonDate: 2008-08-08 14:32:22
Subject: Re: join group by etc

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group