Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f94F25n07861 for ; Thu, 4 Oct 2001 11:02:05 -0400 (EDT) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.4.1) with HTTP id 141646; Thu, 04 Oct 2001 08:02:00 -0700 From: "Josh Berkus" Subject: Re: SQL Syntax / Logic question To: "Michael D. Harlan" , pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.4.1 Date: Thu, 04 Oct 2001 08:02:00 -0700 Message-ID: In-Reply-To: <20011004102712.A29819@beechwoodplace.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="_===141646====davinci.ethosmedia.com===_" X-Archive-Number: 200110/52 X-Sequence-Number: 5007 This is a multi-part MIME message --_===141646====davinci.ethosmedia.com===_ Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Mike, > select frienda, friendb from friends where (select > schools.school from friends,schools where friends.frienda = > schools.person) = (select schools.school from friends,schools where > friends.friendb = schools.person); Too complicated. You need to learn how to use JOINS and table aliases (or find yourself some friends who know SQL!): SELECT friends.frienda, friends.friendb FROM friends JOIN schools schoola ON friends.frienda = schoola.person JOIN schools schoolb ON friends.friendb = schoolb.person WHERE schoola.school = schoolb.school and, if it's possible that any particular person went to more than one school, add: GROUP BY frienda, friendb Simple, neh? -Josh ______AGLIO DATABASE SOLUTIONS___________________________ Josh Berkus Complete information technology josh@agliodbs.com and data management solutions (415) 565-7293 for law firms, small businesses fax 621-2533 and non-profit organizations. San Francisco --_===141646====davinci.ethosmedia.com===_ Content-Type: text/plain Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --_===141646====davinci.ethosmedia.com===_ Content-Type: text/plain Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --_===141646====davinci.ethosmedia.com===_ Content-Type: text/plain Content-Disposition: attachment; filename="" Content-Transfer-Encoding: base64 DQo= --_===141646====davinci.ethosmedia.com===_--