Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5IJx0a60143; Mon, 18 Jun 2001 15:59:00 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id f5IJuF308038; Mon, 18 Jun 2001 15:56:15 -0400 (EDT) To: The Hermit Hacker cc: pgsql-sql@postgresql.org, pgsql-hackers@postgresql.org Subject: Re: LEFT JOIN ... In-reply-to: References: Comments: In-reply-to The Hermit Hacker message dated "Mon, 18 Jun 2001 15:26:41 -0300" Date: Mon, 18 Jun 2001 15:56:15 -0400 Message-ID: <8035.992894175@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200106/270 X-Sequence-Number: 3531 The Hermit Hacker 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