Received: from p1.selectacast.net (IDENT:root@p1.selectacast.net [206.41.1.251]) by hub.org (8.9.3/8.9.3) with ESMTP id TAA59598 for ; Tue, 23 May 2000 19:47:59 -0400 (EDT) (envelope-from jks@selectacast.net) Received: from selectacast.net (IDENT:jks@d1 [209.219.91.66]) by p1.selectacast.net (8.9.3/8.9.3) with ESMTP id TAA22125; Tue, 23 May 2000 19:46:58 -0400 Message-ID: <392B1871.4AB5CAB@selectacast.net> Date: Tue, 23 May 2000 19:46:57 -0400 From: Joseph Shraibman Organization: Xtenit X-Mailer: Mozilla 4.72 [en] (X11; U; Linux 2.2.15 i686) X-Accept-Language: en MIME-Version: 1.0 To: Tom Lane CC: "pgsql-sql@postgresql.org" Subject: Re: two fields in subselect References: <392B0BFC.BB2CD23B@selectacast.net> <4746.959124752@sss.pgh.pa.us> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200005/112 Tom Lane wrote: > Joseph Shraibman writes: > > I want to do this: > > SELECT a, (select x,y,z from table2 where table1.a = table2.w), b, c > > from table1; > > But postgres complains: > > ERROR: Subselect must have only one field > > You haven't said what you expect to happen if table2 has zero or > multiple matches to any one table1.a value --- but if you want a > plain inner join you could do > > SELECT a, x, y, z, b, c from table1, table2 where table1.a = table2.w; > I can't do that. I guess I should have elaborated some more. What I really want to do is: SELECT a, (select x,y,z from table2 where table1.a = table2.w), b, (select x,y,z from table2 where table1.b = table2.w), c from table1; And table2.w is unique.