Re: LEFT JOIN ...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: The Hermit Hacker <scrappy(at)hub(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org, pgsql-hackers(at)postgresql(dot)org
Subject: Re: LEFT JOIN ...
Date: 2001-06-18 19:56:15
Message-ID: 8035.992894175@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-sql

The Hermit Hacker <scrappy(at)hub(dot)org> writes:
>> Try adding ... AND n.nid = 15748 ... to the WHERE.

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

Ooops, I misread "n.nid = nl.nid" as "n.nid = nl.id". Sorry for the
bogus advice.

Try rephrasing as

FROM (note_links nl JOIN notes n ON (n.nid = nl.nid))
LEFT JOIN calendar c ON (n.nid = c.nid)
WHERE ...

The way you were writing it forced the LEFT JOIN to be done first,
whereas what you want is for the note_links-to-notes join to be done
first. See
http://www.ca.postgresql.org/users-lounge/docs/7.1/postgres/explicit-joins.html

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Cary O'Brien 2001-06-18 20:05:53 Index files grow forever?
Previous Message Tom Lane 2001-06-18 19:49:55 Re: timestamp with/without time zone

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-06-18 20:15:26 Re: Subselects, the Oracle way
Previous Message The Hermit Hacker 2001-06-18 19:14:02 Re: Better Archives?