Re: Query, view join question.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)nl>
Cc: vhikida(at)inreach(dot)com, "Pgsql-General (E-mail)" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Query, view join question.
Date: 2005-01-06 19:34:36
Message-ID: 19054.1105040076@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

"Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2005-01-06 19:43:08 Re: Editor: Syntax highlighting and stored procedures surrounded
Previous Message vhikida 2005-01-06 19:34:16 Re: Query, view join question.