Re: [GENERAL] JOIN exclusion problem - Mailing list pgsql-general

From Anja Speerforck
Subject Re: [GENERAL] JOIN exclusion problem
Date
Msg-id 199907011718.NAA24299@chet.brysonweb.com
Whole thread Raw
In response to Re: [GENERAL] JOIN exclusion problem  ("Ross J. Reedstrom" <reedstrm@wallace.ece.rice.edu>)
List pgsql-general
Thanks Peter and Ross for suggesting the correct solution.  It works with
the following code:

SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, k.name1,
ap.telefon, ap.fax, ap.email
                FROM ansprechpartner ap, kunden k
                WHERE ap.kunden_nr = k.kunden_nr
                UNION
                SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ag.name1,
ap.telefon, ap.fax, ap.email
                FROM ansprechpartner ap, agenturen ag
                WHERE ap.agentur_nr = ag.agentur_nr
                ORDER BY nachname;

Best regards,

Anja

At 09:49 01.07.99 -0500, you wrote:
>Ah, now it's clear. You're looking for the UNION operator, and two selects.
>Something like:
>
>SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ap.telefon, ap.fax,
>ap.email, ap.kunden_nr, k.name1
>FROM ansprechpartner ap, kunden k
>WHERE ap.kunden_nr = k.kunden_nr
>UNION
>SELECT apartner_nr, ap.anrede, ap.vorname, ap.nachname, ap.telefon, ap.fax,
>ap.email, ap.agentur_nr, ag.name1
>FROM ansprechpartner ap, agenturen ag
>WHERE  ap.agentur_nr = ag.agentur_nr
>ORDER BY nachname
_____________________________

>In this case you should try a union like
>SELECT ... FROM ap, k WHERE ap.kunden_nr = k.kunden_nr
>UNION
>SELECT ... FROM ap, ag WHERE ap.agentur_nr = ag.agentur_nr
>ORDER BY nachname;
>
>(Note the target lists.)

pgsql-general by date:

Previous
From: Michael Edwin Haberman
Date:
Subject: help with SPI_ Please
Next
From: Leon
Date:
Subject: Bounced bugreport