X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0E42FD1E7FD for ; Thu, 13 May 2004 05:29:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 33375-01 for ; Thu, 13 May 2004 05:29:13 -0300 (ADT) Received: from matrix.gatewaynet.com (matrix.gatewaynet.com [217.19.69.50]) by svr1.postgresql.org (Postfix) with ESMTP id 51291D1E7D1 for ; Thu, 13 May 2004 05:29:10 -0300 (ADT) Received: from matrix.gatewaynet.com (localhost.localdomain [127.0.0.1]) by matrix.gatewaynet.com (8.12.8/8.12.8) with ESMTP id i4D7YRFr021933; Thu, 13 May 2004 10:34:27 +0300 Received: from localhost (achill@localhost) by matrix.gatewaynet.com (8.12.8/8.12.8/Submit) with ESMTP id i4D7YQLV021929; Thu, 13 May 2004 10:34:26 +0300 Date: Thu, 13 May 2004 10:34:26 +0300 (EEST) From: Achilleus Mantzios To: "ashok@kalculate.com" Cc: pgsql-sql@postgresql.org Subject: Re: a wierd query In-Reply-To: <323910-220045413878445@M2W099.mail2web.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests=TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200405/118 X-Sequence-Number: 17832 SELECT foo.value from (select string_a as value from main_table UNION select string_b as value from main_table) as foo; O kyrios ashok@kalculate.com egrapse stis May 13, 2004 : > 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 > -- -Achilleus