Re: Query, view join question. - Mailing list pgsql-general

From vhikida@inreach.com
Subject Re: Query, view join question.
Date
Msg-id 59009.146.74.1.99.1105040872.squirrel@146.74.1.99
Whole thread Raw
In response to Re: Query, view join question.  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
I think there is an echo in here :) It's probably me. I pass for the rest
of this thread.

> "Joost Kraaijeveld" <J.Kraaijeveld@Askesis.nl> writes:
>> CREATE OR REPLACE VIEW even AS
>> SELECT DISTINCT abo_his.klantnummer,
>>> abo_his.artikelnummer, abo_his.code_retour,
>>> abo_klt.aantal_abonnementen, abo_klt.afgewerkt
>> FROM abo_his
>> JOIN abo_klt ON abo_his.klantnummer = abo_klt.klantnummer
>> WHERE abo_his.abonnement = 238
>> ORDER BY abo_his.klantnummer, abo_his.artikelnummer,
>>> abo_his.code_retour, abo_klt.aantal_abonnementen, abo_klt.afgewerkt;
>
>> In the table abo_klt there is no record where abo_klt.abonnement = 238
>> and abo_klt.afgewerkt > 0:
>
>> munt=# select * from abo_klt where abonnement = 238 and afgewerkt > 0;
>
> Yes, but the join isn't testing abo_klt.abonnement.  It's testing
> abo_his.abonnement.  If there's a reason to think that rows in the two
> tables with the same klantnummer must also have the same abonnement,
> you have not said what it is.
>
>             regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>



pgsql-general by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: Editor: Syntax highlighting and stored procedures surrounded
Next
From: Eric Brown
Date:
Subject: Re: Editor: Syntax highlighting and stored procedures surrounded by '