pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Yasir Malik <ymalik@cs.stevens-tech.edu>
To: ashok@kalculate.com <ashok@kalculate.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: a wierd query
Date: Thu, 13 May 2004 09:24:10 -0400 (EDT)
Message-ID: <Pine.NEB.4.58.0405130923190.6950@oud-beersal.cs.stevens-tech.edu> (raw)
In-Reply-To: <323910-220045413878445@M2W099.mail2web.com>
References: <323910-220045413878445@M2W099.mail2web.com>

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Yes you can.  Try this:
(select string_A from main_table) union (select string_B from main_table)

Yasir

On Thu, 13 May 2004, ashok@kalculate.com wrote:

> Date: Thu, 13 May 2004 04:07:08 -0400
> From: "ashok@kalculate.com" <ashok@kalculate.com>
> To: pgsql-sql@postgresql.org
> Subject: [SQL] a wierd query
>
> 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.
>
> 4) remarks
>
>     i can get the solution using a temporary table and with repeated
>       "insert into temporary select $column from main_table"
>
>
> thanks in advance
>
> ashok
>
> --------------------------------------------------------------------
> mail2web - Check your email from the web at
> http://mail2web.com/ .
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
>                http://archives.postgresql.org
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (NetBSD)

iQEVAwUBQKN2/+J7vYSSIbWdAQKklQf+JPhyMpbhEVX/4t70r1m6RFPXkm2VgbOz
Dyxkjhbko07c+YcnVbHmk/8D0d+1L0Qx23vytCfvqRS29O5tzwDFrSfHCZQ8WE4C
H7P0377jfa/LxgAeaUNnDfhhGj+qUI649i2QDSzdalVVwKtUl/aKdw0+evveuUXZ
QBYvVeoFU9KrnqBbQNW6AQOM8vfnYG3cxcb87krRy/b2EgZE462o2O3jGhqvlmrU
8eKJCrEnv4t53IOI3J2WECKbuSomTrUAqfUWbpL6g7zrOpkuCTqzTuOrx+7ISMTR
zyY36zUDeOB/A7u3PEh+wQz/Yqdq1Gu9GQ3kIsgao1WA+K3tj1ceKA==
=zMMM
-----END PGP SIGNATURE-----



view thread (16+ messages)  latest in thread

Message-ID: <Pine.NEB.4.58.0405130923190.6950@oud-beersal.cs.stevens-tech.edu>
Permalink:  ../Pine.NEB.4.58.0405130923190.6950@oud-beersal.cs.stevens-tech.edu/
Also on:    postgresql.org/message-id/Pine.NEB.4.58.0405130923190.6950@oud-beersal.cs.stevens-tech.edu

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: ymalik@cs.stevens-tech.edu, ashok@kalculate.com
  Subject: Re: a wierd query
  In-Reply-To: <Pine.NEB.4.58.0405130923190.6950@oud-beersal.cs.stevens-tech.edu>
  References: <323910-220045413878445@M2W099.mail2web.com> <Pine.NEB.4.58.0405130923190.6950@oud-beersal.cs.stevens-tech.edu>

* 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