Re: joining tables

From: Avin Kavish <avinkavish(at)gmail(dot)com>
To: Michel Feinstein <michelfeinstein(at)gmail(dot)com>
Cc: Jack Royal-Gordon <jackrg(at)pobox(dot)com>, TedJones <ted(at)mentra(dot)co(dot)uk>, pgAdmin Support <pgadmin-support(at)postgresql(dot)org>
Subject: Re: joining tables
Date: 2019-09-04 03:23:41
Message-ID: CAFpscOSvoZnbea+ARGY9--Nw5Mj-4BARa+5i1yK0xCKp8znqTQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-support

yes, what you need is a full outer join. How are your actual results
different from the expected ones?

On Wed, Sep 4, 2019 at 4:18 AM Michel Feinstein <michelfeinstein(at)gmail(dot)com>
wrote:

> Also, be aware that this is NOT the postgresql email list, but the pgAdmin
> email list, you would get a lot more help about SQL there.
>
> On Tue, Sep 3, 2019, 19:44 Jack Royal-Gordon <jackrg(at)pobox(dot)com> wrote:
>
>> Let me step back a bit, as I realize upon further reflection that the
>> first method will not work.
>>
>> As far as the issue about two “Ted” records, read it as though I said two
>> “Ted D” records. It refers to two records in the same table with the same
>> key value. If “Ted D” appeared twice in table 1 and twice in table 2, the
>> join would give four resulting records (all combinations of the records
>> from table 1 and the records from table 2 (and the records from table 3) —
>> that’s fundamentally how a join works. If you don’t want that, then make
>> sure that there are no duplicates within each of the tables.
>>
>> > On Sep 3, 2019, at 9:35 AM, TedJones <ted(at)mentra(dot)co(dot)uk> wrote:
>> >
>> > Hi Jack
>> >
>> > I'm not sure if I understand your comment about two 'Ted' fields and
>> > duplication of rows. In the example below there is 'Ted' twice in
>> Table3 1
>> > and 3 and must appear twice as I've shown in the result as the data in
>> the
>> > rest of the row is different. I agree with no duplication of rows if
>> all of
>> > the row is the same.
>> >
>> > Ted
>> >
>> > Table: 1
>> > Author Title Sales Publication Date
>> > Jim A aa I
>> > Ted B bb J
>> > Dave C cc K
>> > Ted D dd L
>> >
>> > Table: 2
>> > Author Publisher
>> > Jim him
>> > Ted me
>> > Dave me
>> > Will you
>> > Gary him
>> >
>> > Table:3
>> > Author Title Country
>> > Ted B UK
>> > Ted D US
>> > Jim A UK
>> > Dave C UK
>> >
>> > Combined table: Result
>> > Author Title Publication Date Publisher Sales
>> Country
>> > Ted B J me bb UK
>> > Ted D L me dd US
>> > Jim A I him aa UK
>> > Dave C K me cc UK
>> > Gary null null him null null
>> > Will null null you null null
>> >
>> >
>> >
>> >
>> > --
>> > Sent from:
>> https://www.postgresql-archive.org/PostgreSQL-pgadmin-support-f2191615.html
>> >
>> >
>>
>>
>>
>>

In response to

Browse pgadmin-support by date

  From Date Subject
Next Message Khushboo Vashi 2019-09-04 04:09:51 Re: Negative values for obj_id: SELECT statements throwing errors in query editor
Previous Message Michel Feinstein 2019-09-03 22:47:50 Re: joining tables