From: Joseph Shraibman <jks@selectacast.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: two fields in subselect
Date: Tue, 23 May 2000 19:46:57 -0400
Message-ID: <392B1871.4AB5CAB@selectacast.net> (raw)
References: <392B0BFC.BB2CD23B@selectacast.net>
<4746.959124752@sss.pgh.pa.us>
Tom Lane wrote:
> Joseph Shraibman <jks@selectacast.net> 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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jks@selectacast.net, tgl@sss.pgh.pa.us
Subject: Re: two fields in subselect
In-Reply-To: <392B1871.4AB5CAB@selectacast.net>
References: <392B0BFC.BB2CD23B@selectacast.net> <4746.959124752@sss.pgh.pa.us> <392B1871.4AB5CAB@selectacast.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox