Received: from mail.virginia.edu (mail.Virginia.EDU [128.143.2.9]) by postgresql.org (8.11.3/8.11.4) with SMTP id g0NI59l42266 for ; Wed, 23 Jan 2002 13:05:10 -0500 (EST) (envelope-from jkanter@virginia.edu) Received: from smtp.mail.virginia.edu by mail.virginia.edu id aa11626; 23 Jan 2002 13:04 EST Received: from jlk3xpc (d-128-19-222.bootp.Virginia.EDU [128.143.19.222]) by smtp.mail.Virginia.EDU (8.9.3/8.9.3) with SMTP id NAA17452 for ; Wed, 23 Jan 2002 13:04:49 -0500 Message-ID: <00d301c1a438$c30bd160$de138f80@virginia.edu> From: Jodi Kanter To: Postgres Admin List Subject: sub selects Date: Wed, 23 Jan 2002 13:07:03 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00D0_01C1A40E.DA171DD0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Archive-Number: 200201/148 X-Sequence-Number: 3035 This is a multi-part message in MIME format. ------=_NextPart_000_00D0_01C1A40E.DA171DD0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I hope this is not too confusing..... I left my column names and table name= s as is but you should get the idea... I am doing the following: select usf_fk from am_spots where ams_pk in ((select min(ams_pk) from am_sp= ots where am_fk>135),(select max(ams_pk) from am_spots where am_fk>135); It works fine but I originally tried this: 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? Also, I need to now embed this entire select statement into another select = statement such as: select spot_identifier from al_spots where als_pk in (SELECT STATMENT ABOVE) Can I do this? Is there any easier way that I cannot see? Any suggestions w= ould be appreciated. Thanks Jodi ------=_NextPart_000_00D0_01C1A40E.DA171DD0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
I hope this is not too confusing..... I left my column names and table= =20 names as is but you should get the idea...
 
I am doing the following:
 
select usf_fk from am_spots where ams_pk in ((select min(ams_pk) from= =20 am_spots where am_fk>135),(select max(ams_pk) from am_spots where=20 am_fk>135);
 
It works fine but I originally tried this:
 
select usf_fk from am_spots where ams_pk in (select min(ams_pk),=20 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=20 the wrong syntax or is it just a postgres rule that you can't pull more tha= n one=20 field back in a sub select?
 
Also, I need to now embed this entire select statement into another se= lect=20 statement such as:
 
select spot_identifier from al_spots where als_pk in (SELECT= =20 STATMENT ABOVE)
 
Can I do this? Is there any easier way that I cannot see? Any suggesti= ons=20 would be appreciated.
Thanks
Jodi
------=_NextPart_000_00D0_01C1A40E.DA171DD0--