From: | "Joost Kraaijeveld" <J(dot)Kraaijeveld(at)Askesis(dot)nl> |
---|---|
To: | "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>, <vhikida(at)inreach(dot)com> |
Cc: | "Pgsql-General (E-mail)" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Query, view join question. |
Date: | 2005-01-06 19:19:26 |
Message-ID: | A3D1526C98B7C1409A687E0943EAC41001EB26@obelix.askesis.nl |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Tom,
pgsql-general-owner(at)postgresql(dot)org schreef:
> "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;
>
> Okay ... but the view is constraining abo_his.abonnement and
> outputting abo_klt.aantal_abonnementen. Why would you assume that
> joining on klantnummer would cause these two fields to necessarily be
> the same?
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;
...
(0 rows)
So I assumed that in no join between abo_his (which has no "afgewerkt" column at all ) and abo_klt (which has 0 records with a "afgewerkt" columns > 0) as created above ( with WHERE abo_his.abonnement = 238) there could be a record with both abonnement = 238 and afgewerk >0.
But there are:
on the view there are :
munt=# select * from even where afgewerkt > 0;
.....
(797 rows)
SO I must understand something wrong...
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
e-mail: J(dot)Kraaijeveld(at)Askesis(dot)nl
web: www.askesis.nl
From | Date | Subject | |
---|---|---|---|
Next Message | Net Virtual Mailing Lists | 2005-01-06 19:26:25 | ltree valid characters |
Previous Message | Tom Lane | 2005-01-06 18:45:59 | Re: pg_dump dependencies |