Received: from mobile.hub.org (SHW12-37.accesscable.net [24.71.155.37]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f5IKHAa68790; Mon, 18 Jun 2001 16:17:10 -0400 (EDT) (envelope-from scrappy@hub.org) Received: from localhost (scrappy@localhost) by mobile.hub.org (8.11.3/8.11.1) with ESMTP id f5IKH0g67016; Mon, 18 Jun 2001 17:17:00 -0300 (ADT) (envelope-from scrappy@hub.org) X-Authentication-Warning: mobile.hub.org: scrappy owned process doing -bs Date: Mon, 18 Jun 2001 17:17:00 -0300 (ADT) From: The Hermit Hacker To: Tom Lane cc: , Subject: Re: LEFT JOIN ... In-Reply-To: <8035.992894175@sss.pgh.pa.us> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200106/272 X-Sequence-Number: 3533 Perfect, thank you ... i knew I was overlooking something obvious ... the query just flies now ... On Mon, 18 Jun 2001, Tom Lane wrote: > 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 > Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy Systems Administrator @ hub.org primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org