Received: from mx99.openu.ac.il (arbel.openu.ac.il [147.233.32.4]) by hub.org (8.9.1/8.9.1) with ESMTP id EAA13642 for ; Wed, 20 Jan 1999 04:44:07 -0500 (EST) (envelope-from herouth@oumail.openu.ac.il) Received: from talmon.openu.ac.il (talmon.openu.ac.il [147.233.32.11]) by mx99.openu.ac.il (Postfix) with ESMTP for id 453134B4A1; Wed, 20 Jan 1999 11:44:04 +0200 (IST) Received: from [147.233.159.109] (mac-herouth.pc.openu.ac.il) by talmon.openu.ac.il (Netscape Messaging Server 3.54) with ESMTP id AAA460B; Wed, 20 Jan 1999 11:45:03 +0200 X-Sender: herouth@shaked.cc.openu.ac.il Message-Id: In-Reply-To: <19990120045127.28717.rocketmail@send103.yahoomail.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Date: Wed, 20 Jan 1999 11:44:01 +0200 To: Dave Inskeep From: Herouth Maoz Subject: Re: [SQL] Beginner question - select with multiple tables Cc: pgsql-sql@postgreSQL.org At 6:51 +0200 on 20/1/99, Dave Inskeep wrote: > > select distinct vall.node from vall, vall_bod1, vall_bod2 where > ( vall.node = vall_bod1.node and vall_bod1.bod1 LIKE '%brake%' ) or > ( vall.node = vall_bod2.node and vall_bod2.bod2 LIKE '%brake%' ); > > However, if I insert a record into vall_bod2 (whether or not it > contains the word brake) and a corresponding header record into vall > with a matching node, the same exact query will return the nodes of > all records in vall_bod1 with the word 'brake' in the bod1 field. > > The same holds true if I query across vall_bod1, 2, and 3, and there > are no records in vall_bod3. If I insert a single record in vall_bod3, > even if it doesn't match, the query will work for matching records in > vall_bod1 and vall_bod2. Ditto when I try across 1-4. > > Can someone explain why this happens, am I doing something wrong? Is > there a better way to achieve the same results, i.e. JOINS? Does > Postgresql support JOINS? First, you *are* doing a join here. But you are missing the logic. Perhaps you should tell us, instead of what query you did (which obviously returns the correct results by your description), what was the result you wanted? What rows did you want to be returned? Herouth -- Herouth Maoz, Internet developer. Open University of Israel - Telem project http://telem.openu.ac.il/~herutma