Problem with complex join

From: Oleg Broytmann <phd(at)sun(dot)med(dot)ru>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Problem with complex join
Date: 1999-02-22 15:24:31
Message-ID: Pine.SOL2.3.96.SK.990222181830.6787A-100000@sun.med.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

I ran a query:
SELECT p.subsec_id, p.pos_id, cn.pos_id
FROM central cn, shops sh, districts d, positions p
WHERE cn.shop_id = sh.shop_id AND sh.distr_id = d.distr_id
AND d.city_id = 1 ;

and got a huge list, where, are, e.g:
subsec_id|pos_id|pos_id
---------+------+------
1| 1| 1
1| 1| 1
1| 1| 1
1| 1| 1
[skipped]
1| 2| 1
1| 2| 2
1| 2| 2
1| 2| 2

and so on.

I modified the query to exclude rows:

SELECT p.subsec_id, p.pos_id, cn.pos_id
FROM central cn, shops sh, districts d, positions p
WHERE cn.shop_id = sh.shop_id AND sh.distr_id = d.distr_id
AND d.city_id = 1 AND cn.pos_id = p.pos_id ;

but got 0 rows as a result. I expected:
subsec_id|pos_id|pos_id
---------+------+------
1| 1| 1
[skipped]
1| 2| 2

Is it a bug?

Oleg.
----
Oleg Broytmann http://members.xoom.com/phd2/ phd2(at)earthling(dot)net
Programmers don't die, they just GOSUB without RETURN.

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Davis 1999-02-22 16:04:35 RE: [HACKERS] Re: Max backend limits cleaned up
Previous Message Tom Lane 1999-02-22 15:10:22 Re: [HACKERS] Re: Max backend limits cleaned up