Received: from mailo.vtcif.telstra.com.au (mailo.vtcif.telstra.com.au [202.12.144.17]) by hub.org (8.9.3/8.9.3) with ESMTP id XAA67524 for ; Wed, 2 Feb 2000 23:50:02 -0500 (EST) (envelope-from chrisb@nimrod.itg.telstra.com.au) Received: (from uucp@localhost) by mailo.vtcif.telstra.com.au (8.8.2/8.6.9) id PAA19177; Thu, 3 Feb 2000 15:49:30 +1100 (EST) Received: from maili.vtcif.telstra.com.au(202.12.142.17) via SMTP by mailo.vtcif.telstra.com.au, id smtpdNNr29_; Thu Feb 3 15:48:56 2000 Received: (from uucp@localhost) by maili.vtcif.telstra.com.au (8.8.2/8.6.9) id PAA22559; Thu, 3 Feb 2000 15:48:54 +1100 (EST) Received: from localhost(127.0.0.1), claiming to be "mail.cdn.telstra.com.au" via SMTP by localhost, id smtpdT2V94_; Thu Feb 3 15:48:09 2000 Received: from lunitari.nimrod.itg.telecom.com.au (lunitari.nimrod.itg.telecom.com.au [192.53.254.48]) by mail.cdn.telstra.com.au (8.8.2/8.6.9) with ESMTP id PAA26500; Thu, 3 Feb 2000 15:48:09 +1100 (EST) Received: from nimrod.itg.telecom.com.au (majere [192.53.254.45]) by lunitari.nimrod.itg.telecom.com.au (8.9.1/8.9.3) with ESMTP id PAA12699; Thu, 3 Feb 2000 15:47:28 +1100 (EST) Sender: chrisb@nimrod.itg.telstra.com.au Message-ID: <38990833.49C7E70D@nimrod.itg.telecom.com.au> Date: Thu, 03 Feb 2000 15:46:43 +1100 From: Chris Bitmead Reply-To: chris@bitmead.com Organization: IBM Global Services X-Mailer: Mozilla 4.6 [en] (X11; I; SunOS 5.6 sun4u) X-Accept-Language: en MIME-Version: 1.0 To: sec@proaxis.com CC: pgsql-sql@postgreSQL.org Subject: Re: [SQL] SQL Query help needed - newbie question References: <00020220331102.00960@localhost.localdomain> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Scott Chapman wrote: > > I am new to SQL and PostgreSQL and I'm not sure how to get this done in one > query: > > I have 3 tables: > > Vendor > ------ > VendorNumber > EmailAddress > ..... > > CrossReference > -------------- > VendorNumber > PartType > SystemType > > PartRequest > -------- > RequestNumber > PartType > SystemType > ..... > > I am processing the Parts Requests. > > I need a query that returns the PartRequest.RequestNumber and > Vendor.EmailAddress so I can send the Request to all Vendors that carry the > requested PartType & SystemType combinations of parts. SELECT RequestNumber, EmailAddress FROM PartRequest, Vendor, CrossReference WHERE Vendor.VendorNumber = CrossReference.VendorNumber AND CrossReference.PartType = CrossReference.PartType AND CrossReference.SystemType = PartRequest.SystemType; > > So a given Request may be for a PartType of PrinterCable and SystemType of > Macintosh. > > The CrossReference table has a list of all vendors that carry PrinterCables for > Macintoshes. > > I am using PostgreSQL so I don't have foreign keys and I'm not sure enough of > SQL yet to know if that's a problem. > > Can someone here please help me with this query? > Thanks! > -- > Scott Chapman sends.... > sec@proaxis.com > > ************