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 1im2dC-0000GC-Ie for pgsql-general@arkaria.postgresql.org; Mon, 30 Dec 2019 21:31:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1im2dB-0006lL-CG for pgsql-general@arkaria.postgresql.org; Mon, 30 Dec 2019 21:31:17 +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 1im2dB-0006lE-2M for pgsql-general@lists.postgresql.org; Mon, 30 Dec 2019 21:31:17 +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 1im2d8-0003bO-5X for pgsql-general@lists.postgresql.org; Mon, 30 Dec 2019 21:31:16 +0000 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mailbackend.panix.com (Postfix) with ESMTP id 47mrG7448qzrmJ for ; Mon, 30 Dec 2019 16:31:11 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 17622) id 47mrG666nJzfYc; Mon, 30 Dec 2019 16:31:10 -0500 (EST) Date: Mon, 30 Dec 2019 16:31:10 -0500 From: stan To: pgsql-general@lists.postgresql.org Subject: A JOIN question Message-ID: <20191230213110.GA4475@panix.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 I am working on a system whee one group of folks inputs portions of data into a table, and a 2nd completes the data for each row. The engineers enter in the items they need into a BOM table, and purchasing agents get quotes and create PO's. There is not a fixed relationship between the parts (part number and manufacturers) and the vendor (mfg agent or distributor), A project manager determines which vendor to buy various manufacturers items from. This sis controlled by the following table: CREATE TABLE mfg_vendor_relationship ( mfg_vendor_relationship_key_serial integer DEFAULT nextval('ica.mfg_vendor_relationship_key_serial') PRIMARY KEY , mfg_key integer NOT NULL, vendor_key integer NOT NULL, project_key integer NOT NULL, modtime timestamptz NOT NULL DEFAULT current_timestamp , FOREIGN KEY (mfg_key) references mfg(mfg_key) ON DELETE RESTRICT , FOREIGN KEY (vendor_key) references vendor(vendor_key) ON DELETE RESTRICT , FOREIGN KEY (project_key) references project(project_key) ON DELETE RESTRICT , CONSTRAINT mfg_vendor_constraint UNIQUE ( mfg_key , vendor_key , project_key ) ); So, I have the following view for the purchasing agents. CREATE view t1 as select project.proj_no , qty , costing_unit.unit, mfg_part.mfg_part_no , mfg.name as m_name , mfg_part.descrip as description , vendor.name as v_name , format_phone_no( vendor.area_code, vendor.phone_exchange, vendor.phone_number, vendor.phone_extension) office_phone , cast(cost_per_unit as money) , cast(qty * cost_per_unit as money) line_ttl , need_date , order_date , received_date , po_no , po_line_item , po_revision , po_rev_date , po_terms_and_conditions.net_interval , po_terms_and_conditions.discount_interval , po_terms_and_conditions.discount from bom_item right join project on project.project_key = bom_item.project_key inner join mfg_part on mfg_part.mfg_part_key = bom_item.mfg_part_key inner join costing_unit on costing_unit.costing_unit_key = bom_item.costing_unit_key inner join mfg on mfg.mfg_key = mfg_part.mfg_key inner join mfg_vendor_relationship on mfg_vendor_relationship.mfg_key = mfg_part.mfg_key AND mfg_vendor_relationship.project_key = bom_item.project_key inner join vendor on mfg_vendor_relationship.vendor_key = vendor.vendor_key FULL OUTER JOIN po_terms_and_conditions ON po_terms_and_conditions.po_terms_and_conditions_key = bom_item.po_terms_and_conditions_key ; Now, my problem is that this join: inner join mfg_vendor_relationship on mfg_vendor_relationship.mfg_key = mfg_part.mfg_key AND mfg_vendor_relationship.project_key = bom_item.project_key Means that the item to be purchased is invisible to the purchasing agent if the project manager has not populated the cross reference table. How can I modify this select so that all items for a given project will appear in the purchasing agents view? -- "They that would give up essential liberty for temporary safety deserve neither liberty nor safety." -- Benjamin Franklin