pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Joseph Shraibman <jks@selectacast.net>
Cc: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: Re: two fields in subselect
Date: Tue, 23 May 2000 19:32:32 -0400
Message-ID: <4746.959124752@sss.pgh.pa.us> (raw)
In-Reply-To: <392B0BFC.BB2CD23B@selectacast.net>
References: <392B0BFC.BB2CD23B@selectacast.net>

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;

			regards, tom lane



view thread (3+ messages)  latest in thread

Message-ID: <4746.959124752@sss.pgh.pa.us>
Permalink:  ../4746.959124752@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4746.959124752@sss.pgh.pa.us

 · 

reply

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: tgl@sss.pgh.pa.us, jks@selectacast.net
  Subject: Re: two fields in subselect
  In-Reply-To: <4746.959124752@sss.pgh.pa.us>
  References: <392B0BFC.BB2CD23B@selectacast.net> <4746.959124752@sss.pgh.pa.us>

* 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