From: | Peter Eisentraut <peter(at)pathwaynet(dot)com> |
---|---|
To: | Anja Speerforck <anja(at)damn(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] JOIN exclusion problem |
Date: | 1999-06-30 18:02:35 |
Message-ID: | Pine.LNX.4.10.9906301401040.30903-100000@uruguay.pathwaynet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wed, 30 Jun 1999, Anja Speerforck wrote:
> Hello,
>
> I'm trying to join three tables, where I need only one piece of data from
> two of the tables. The code I wrote is:
>
> SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ap.telefon, ap.fax,
> ap.email, ap.kunden_nr, k.name1, ap.agentur_nr, ag.name1
> FROM ansprechpartner ap, kunden k, agenturen ag
> WHERE ap.kunden_nr = k.kunden_nr OR ap.agentur_nr = ag.agentur_nr
^^
You might wanna try an AND there.
> ORDER BY nachname"
>
> The problem is that each row from each table is combined with each row of
> the other tables. I know the code is wrong, but I don't know how to write
> it so that the results show only the actual value of ag.name1 and k.name1,
> and not all of the possible combinations.
>
> Is there a way of limiting how the rows are built up? Pardon for novice
> nature of this question...
--
Peter Eisentraut
PathWay Computing
From | Date | Subject | |
---|---|---|---|
Next Message | Lauri Posti | 1999-06-30 18:39:28 | large objects |
Previous Message | Anja Speerforck | 1999-06-30 17:11:35 | JOIN exclusion problem |