pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Silke Trißl <trissl@informatik.hu-berlin.de>
To: ashok@kalculate.com, SQL PostgreSQL <pgsql-sql@postgresql.org>
Subject: Re: a wierd query
Date: Thu, 13 May 2004 10:41:10 +0200
Message-ID: <40A334A6.5010400@informatik.hu-berlin.de> (raw)
References: <323910-220045413878445@M2W099.mail2web.com>



ashok@kalculate.com schrieb:

>hi 
>
>i have a wierd problem and i require an equally weird query.
>1) backgound
>  Table test:
>    CREATE TABLE main_table (
>               string_A varchar( 20),
>               string_B varchar( 20),
>               );
>     -- both columns are identical in nature and usage
>     INSERT INTO main_table VALUES('abcd','qrst');
>     INSERT INTO main_table VALUES('efgh','efgh');
>     INSERT INTO main_table VALUES('ijkl','abcd');
>     INSERT INTO main_table VALUES('abcd','ijkl');
>     INSERT INTO main_table VALUES('qrst','uvwx');
>
>2) problem:
>   
>     i require a query that gives me a result set of the form
>
>   'abcd'
>   'efgh'
>   'ijkl'
>   'qrst'
>   'uvwx'
>
>   that is i require the dictinct values from (visualizing each column
>result as a set) the union of the two columns
>
>3) questions
>
>   a) is a query like this possible that can give me the desired result
>   b) if so what would it be.
>

Yes, the follwoing
 select t1.string_a from main_table t1
union
select t2.string_b from main_table t2;

>
>4) remarks
>   
>    i can get the solution using a temporary table and with repeated
>      "insert into temporary select $column from main_table"
>  
>
Why, SQL does the trick!


>
>thanks in advance
>
>ashok
>
>  
>

Silke

>  
>





view thread (16+ messages)  latest in thread

Message-ID: <40A334A6.5010400@informatik.hu-berlin.de>
Permalink:  ../40A334A6.5010400@informatik.hu-berlin.de/
Also on:    postgresql.org/message-id/40A334A6.5010400@informatik.hu-berlin.de

 · 

reply

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: trissl@informatik.hu-berlin.de
  Subject: Re: a wierd query
  In-Reply-To: <40A334A6.5010400@informatik.hu-berlin.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