pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: The Hermit Hacker <scrappy@hub.org>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Cc: pgsql-hackers@postgresql.org
Subject: Re: LEFT JOIN ...
Date: Mon, 18 Jun 2001 15:26:41 -0300 (ADT)
Message-ID: <Pine.BSF.4.33.0106181525140.22744-100000@mobile.hub.org> (raw)
In-Reply-To: <7462.992887658@sss.pgh.pa.us>

On Mon, 18 Jun 2001, Tom Lane wrote:

> The Hermit Hacker <scrappy@hub.org> writes:
> >       FROM note_links nl, notes n LEFT JOIN calendar c ON (n.nid = c.nid)
> >       WHERE (n.type = 'A' OR n.type = 'N' OR n.type = 'H' OR n.type = 'C')
> >             AND (nl.id = 15748 AND contact_lvl = 'company')
> >             AND n.nid = nl.nid
> >       ORDER BY start DESC;
>
> > Is there some way to write the above so that it evaluates:
> > first, so that it only has to do the LEFT JOIN on the *one* n.nid that is
> > returned, instead of the 86736 that are in the table?
>
> Try adding ... AND n.nid = 15748 ...  to the WHERE.  It's not very
> bright about making that sort of transitive-equality deduction for
> itself...

n.nid is the note id ... nl.id is the contact id ...

I'm trying to pull out all notes for the company with an id of 15748:

sepick=# select * from note_links where id = 15748;
  nid  |  id   | contact_lvl | owner
-------+-------+-------------+-------
 84691 | 15748 | company     | f
(1 row)





view thread (13+ messages)  latest in thread

Message-ID: <Pine.BSF.4.33.0106181525140.22744-100000@mobile.hub.org>
Permalink:  ../Pine.BSF.4.33.0106181525140.22744-100000@mobile.hub.org/
Also on:    postgresql.org/message-id/Pine.BSF.4.33.0106181525140.22744-100000@mobile.hub.org

 · 

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: scrappy@hub.org, tgl@sss.pgh.pa.us, pgsql-hackers@postgresql.org
  Subject: Re: LEFT JOIN ...
  In-Reply-To: <Pine.BSF.4.33.0106181525140.22744-100000@mobile.hub.org>
  References: <7462.992887658@sss.pgh.pa.us> <Pine.BSF.4.33.0106181525140.22744-100000@mobile.hub.org>

* 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