X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id BBC8914B281B for ; Wed, 11 Aug 2004 15:56:51 -0300 (ADT) 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 67888-02 for ; Wed, 11 Aug 2004 18:56:43 +0000 (GMT) Received: from 10.hostcorporate.com (unknown [69.41.231.186]) by svr1.postgresql.org (Postfix) with SMTP id A25E314B2806 for ; Wed, 11 Aug 2004 15:56:41 -0300 (ADT) Received: (qmail 2112 invoked from network); 11 Aug 2004 18:49:10 -0000 Received: from localhost (HELO localhost.localdomain) (127.0.0.1) by localhost.10.hostcorporate.com with SMTP; 11 Aug 2004 18:49:10 -0000 Message-ID: <411A6B94.3080807@zara.6.isreserved.com> Date: Thu, 12 Aug 2004 01:55:16 +0700 From: David Garamond User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7b) Gecko/20040421 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Andreas Haumer , pgsql-sql@postgresql.org Subject: Re: Displaying two tables side by side References: <411A2926.9020500@zara.6.isreserved.com> <411A5976.4090502@xss.co.at> In-Reply-To: <411A5976.4090502@xss.co.at> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200408/91 X-Sequence-Number: 18588 Andreas Haumer wrote: > You could try to use PosgreSQL's ctid system column to join on like this: > > test=# select *,ctid from t1; > a | b | ctid > - ---+---+------- > 2 | 2 | (0,1) > 3 | 5 | (0,2) > 4 | 7 | (0,3) > 9 | 0 | (0,4) > > > test=# select *,ctid from t2; > c | d | ctid > - ---+---+------- > 4 | 5 | (0,1) > 7 | 3 | (0,2) > 3 | 2 | (0,3) > 1 | 1 | (0,4) > 2 | 0 | (0,5) > > > test=# select * from t1 right outer join t2 on (t1.ctid=t2.ctid); > a | b | c | d > - ---+---+---+--- > 2 | 2 | 4 | 5 > 3 | 5 | 7 | 3 > 4 | 7 | 3 | 2 > 9 | 0 | 1 | 1 > | | 2 | 0 > > > Note that this is of course very platform specific. On Oracle > you could use rownum, for example. > I don't have a more portable solution on hand right now. > > HTH Thanks, I just found out about ctid. I was thinking on a rownum equivalent too, actually. I guess a more portable solution would be creating a temporary table for each table to add the ctid/"row counter" equivalent, and then join on that. -- dave