Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1im3IC-000202-W3 for pgsql-general@arkaria.postgresql.org; Mon, 30 Dec 2019 22:13:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1im3IA-0002pB-0v for pgsql-general@arkaria.postgresql.org; Mon, 30 Dec 2019 22:13:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1im3I9-0002p4-N5 for pgsql-general@lists.postgresql.org; Mon, 30 Dec 2019 22:13:37 +0000 Received: from mailbackend.panix.com ([166.84.1.89]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1im3I1-0003uA-S4 for pgsql-general@lists.postgresql.org; Mon, 30 Dec 2019 22:13:36 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 47msBw0CwYztsh; Mon, 30 Dec 2019 17:13:27 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 17622) id 47msBr0KNgzfYc; Mon, 30 Dec 2019 17:13:23 -0500 (EST) Date: Mon, 30 Dec 2019 17:13:23 -0500 From: stan To: Michael Lewis Cc: pgsql-general@lists.postgresql.org Subject: Re: A JOIN question Message-ID: <20191230221323.GA2064@panix.com> References: <20191230213110.GA4475@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Editor: gVim User-Agent: Mutt/1.12.1 (2019-06-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, Dec 30, 2019 at 02:47:53PM -0700, Michael Lewis wrote: > > > > LEFT join mfg_vendor_relationship on > > mfg_vendor_relationship.mfg_key = mfg_part.mfg_key > > AND > > mfg_vendor_relationship.project_key = bom_item.project_key > > LEFT join vendor on > > mfg_vendor_relationship.vendor_key = vendor.vendor_key > > > > Perhaps I am missing something, but it seems like just a matter of changing > inner join to left so you keep what you already have and augment vendor > information when it exists. I never use right joins (I re-write to always > declare as left) so I am not sure if the right join near the top screws > that up. I might consider using a UNION ALL to combine sets where values > are NULL with left joins, and use plain (inner) joins for the not nulls. Thanks. That looks like it gives me what I need. RE right joins, I just got started doing that, and it is easier for me to think that way. -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin