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 6A6EED1E7E1 for ; Thu, 13 May 2004 05:29:28 -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 30756-04 for ; Thu, 13 May 2004 05:29:09 -0300 (ADT) Received: from mail.informatik.hu-berlin.de (mail.informatik.hu-berlin.de [141.20.20.50]) by svr1.postgresql.org (Postfix) with ESMTP id 48DFDD1E791 for ; Thu, 13 May 2004 05:29:06 -0300 (ADT) Received: from informatik.hu-berlin.de (karotte [141.20.27.143]) (authenticated bits=0) by mail.informatik.hu-berlin.de (8.12.10/8.12.10/INF-2.0-MA-SOLARIS-2.8) with ESMTP id i4D8T4IC000087; Thu, 13 May 2004 10:29:04 +0200 (MEST) Message-ID: <40A334A6.5010400@informatik.hu-berlin.de> Date: Thu, 13 May 2004 10:41:10 +0200 From: =?ISO-8859-1?Q?Silke_Tri=DFl?= User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; de-DE; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: de-de, de MIME-Version: 1.0 To: ashok@kalculate.com, SQL PostgreSQL Subject: Re: a wierd query References: <323910-220045413878445@M2W099.mail2web.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/117 X-Sequence-Number: 17831 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 > >