pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Dave Inskeep <dinskeep@yahoo.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Beginner question - select with multiple tables
Date: Wed, 20 Jan 1999 11:44:01 +0200
Message-ID: <l03110702b2cb5338c36b@[147.233.159.109]> (raw)
In-Reply-To: <19990120045127.28717.rocketmail@send103.yahoomail.com>

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





view thread (5+ messages)  latest in thread

Message-ID: <l03110702b2cb5338c36b@[147.233.159.109]>
Permalink:  ../l03110702b2cb5338c36b@%5B147.233.159.109%5D/
Also on:    postgresql.org/message-id/l03110702b2cb5338c36b@[147.233.159.109]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, dinskeep@yahoo.com
  Subject: Re: [SQL] Beginner question - select with multiple tables
  In-Reply-To: <l03110702b2cb5338c36b@[147.233.159.109]>
  References: <19990120045127.28717.rocketmail@send103.yahoomail.com> <l03110702b2cb5338c36b@[147.233.159.109]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox