From: Tim Landscheidt <tim@tim-landscheidt.de>
To: pgsql-sql@postgresql.org
Subject: Re: Add one column to another
Date: Thu, 25 Aug 2011 17:50:14 +0000
Message-ID: <m3vctlqt2h.fsf@passepartout.tim-landscheidt.de> (raw)
References: <4E565A4E.9060400@gmail.com>
(anonymous) wrote:
> I have to deal with a table which contains:
> first_name
> surname
> email1
> email2
> ... and I would like to create a view which combines both email columns thus:
> first_name
> surname
> email
> It looks simple but I can't think of an obvious query.
Try:
| SELECT first_name, surname, email1 AS email FROM testtable WHERE email1 IS NOT NULL UNION ALL
| SELECT first_name, surname, email2 AS email FROM testtable WHERE email2 IS NOT NULL;
Tim
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tim@tim-landscheidt.de
Subject: Re: Add one column to another
In-Reply-To: <m3vctlqt2h.fsf@passepartout.tim-landscheidt.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox