X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 14BB052A56 for ; Mon, 14 Mar 2005 02:40:46 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 35677-02 for ; Mon, 14 Mar 2005 02:40:42 +0000 (GMT) Received: from pws.com.au (mail.pws.com.au [210.23.138.139]) by svr1.postgresql.org (Postfix) with SMTP id A45A156480 for ; Mon, 14 Mar 2005 02:39:23 +0000 (GMT) Received: (qmail 6533 invoked from network); 14 Mar 2005 02:39:23 -0000 Received: from unknown (HELO wizzard.pws.com.au) (russell@pws.com.au@138.217.54.70) by mail.pws.com.au with SMTP; 14 Mar 2005 02:39:23 -0000 From: Russell Smith To: Steven Verhoeven Subject: Re: sql question Date: Mon, 14 Mar 2005 13:39:20 +1100 User-Agent: KMail/1.7 Cc: pgsql-general@postgresql.org, pgsql-novice@postgresql.org References: <423190C1.5090406@dmbr.UGent.be> In-Reply-To: <423190C1.5090406@dmbr.UGent.be> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200503141339.21286.mr-russ@pws.com.au> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.005 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/573 X-Sequence-Number: 74888 On Fri, 11 Mar 2005 11:36 pm, Steven Verhoeven wrote: > Hi all > > My table definition : > > id | fref | mref > ------+-----------+---------- > 1 | 23 | 25 > 2 | 24 | 28 > 3 | 25 | 31 > 4 | 26 | 34 > > My problem : > i need a query that results in this : > > id | ref > ------+---------- > 1 | 23 > 1 | 25 > 2 | 24 > 2 | 28 > 3 | 25 > 3 | 31 > 4 | 26 > 4 | 34 > SELECT id, fref as ref FROM table UNION ALL SELECT id, mref as ref FROM table; Should do the trick. > > Do I need a crosstab-query ? > Who can help me ? > >