pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: G. Anthony Reina <reina@nsi.edu>
To: reina@nsi.edu, "pgsql-questions@postgresql.org" <pgsql-sql@postgreSQL.org>
Subject: Having trouble with join
Date: Thu, 24 Sep 1998 17:49:41 -0700
Message-ID: <360AE8A5.15CDE741@nsi.edu> (raw)

I have a subquery that I'd like to make a join instead to see if it is
any faster. 

subquery:  select distinct cell from center_out_cell where rep in
(select rep from center_out_opto where marker = 5);

All this does is find the occurrences of 'cell' that have 'marker' = 5.
However, 'cell' is defined in table center_out_cell and 'marker' is
defined in table 'center_out_opto'. Both tables have 'rep' so that ties
them together. The subquery gives me the correct results.

I tried this for a join but didn't get the right result:

select distinct cc.cell from center_out_cell cc, center_out_opto co
where co.marker = 5 and co.rep = cc.rep;

Can anyone tell me what I'm doing wrong?
Does this sound more like a subquery or a join?

Thanks
-Tony
-- 

                        ( @@ )
 ////////////////////oOO*(__)*OOo///////////////////////
//                                                    //
// G. Anthony Reina, MD                               //
// The Neurosciences Institute                        //
// 10640 John Jay Hopkins Drive                       //
// San Diego, CA   92121  USA                         //
//                                                    //
// Voice: (619) 626-2000     FAX: (619) 626-2199      //
// E-mail: reina@nsi.edu                              //
//                                                    //
///////////////////////////////////////////////////////



Message-ID: <360AE8A5.15CDE741@nsi.edu>
Permalink:  ../360AE8A5.15CDE741@nsi.edu/
Also on:    postgresql.org/message-id/360AE8A5.15CDE741@nsi.edu

 · 

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: reina@nsi.edu
  Subject: Re: Having trouble with join
  In-Reply-To: <360AE8A5.15CDE741@nsi.edu>
  References: <360AE8A5.15CDE741@nsi.edu>

* 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