Re: strange behvaviour in join? BUG in 7.02?

From: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
To: Radoslaw Stachowiak <radek(at)alter(dot)pl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: strange behvaviour in join? BUG in 7.02?
Date: 2000-11-10 14:01:09
Message-ID: 200011101401.eAAE1A526872@linda.lfix.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Radoslaw Stachowiak wrote:
>I have PSQL 7.02
>
>classic join on Two tables:
>
>select l.id from linia l,lk_strefa2linia lk
>where l.id = lk.fk_linia and lk.fk_strefa=5;
>
>gives correct linia.ids.
>
>but
>select linia.id from linia l,lk_strefa2linia lk
>where l.id = lk.fk_linia and lk.fk_strefa=5;
>
>(the only difference is second word: linia.id instead l.id)
>will give totaly different results).

You are actually doing a 3-way join, with linia included twice.
It is implicitly included a second time when a column is referenced
from it without the alias.

--
Oliver Elphick Oliver(dot)Elphick(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"But thanks be to God, which giveth us the victory
through our Lord Jesus Christ."
I Corinthians 15:57

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Nelio Alves Pereira Filho 2000-11-10 14:46:51 Union & Nested queries
Previous Message Vilson farias 2000-11-10 12:43:13 Sequencial scan over primary keys 2