pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Jodi Kanter <jkanter@virginia.edu>
Cc: Postgres Admin List <pgsql-admin@postgresql.org>
Subject: Re: sub selects
Date: Wed, 23 Jan 2002 14:05:21 -0500
Message-ID: <4550.1011812721@sss.pgh.pa.us> (raw)
In-Reply-To: <00d301c1a438$c30bd160$de138f80@virginia.edu>
References: <00d301c1a438$c30bd160$de138f80@virginia.edu>

Jodi Kanter <jkanter@virginia.edu> writes:
> select usf_fk from am_spots where ams_pk in (select min(ams_pk), max(ams_pk=
> ) from am_spots where am_fk>135);

> I received an error saying that my subselect has too many fields. Did I use=
>  the wrong syntax or is it just a postgres rule that you can't pull more th=
> an one field back in a sub select?

It's an SQL92 rule: if you are doing "foo IN (subselect)" then the
subselect must return one column to compare to foo.  You are confusing
this case with "foo IN (scalar expression, scalar expression, ...)"
which is actually quite a different construct.

			regards, tom lane



view thread (4+ messages)  latest in thread

Message-ID: <4550.1011812721@sss.pgh.pa.us>
Permalink:  ../4550.1011812721@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/4550.1011812721@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-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, jkanter@virginia.edu
  Subject: Re: sub selects
  In-Reply-To: <4550.1011812721@sss.pgh.pa.us>
  References: <00d301c1a438$c30bd160$de138f80@virginia.edu> <4550.1011812721@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