Problem with complex join

Поиск
Список
Период
Сортировка
Искать

Problem with complex join

От:
Oleg Broytmann <phd@sun.med.ru>
Дата:
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@earthling.net          Programmers don't die, they just GOSUB without RETURN.


FAQ