Re: two fields in subselect

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Joseph Shraibman <jks(at)selectacast(dot)net>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: two fields in subselect
Date: 2000-05-23 23:32:32
Message-ID: 4746.959124752@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Joseph Shraibman <jks(at)selectacast(dot)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;

regards, tom lane

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Joseph Shraibman 2000-05-23 23:46:57 Re: two fields in subselect
Previous Message Joseph Shraibman 2000-05-23 22:53:48 two fields in subselect