Re: Self Join Help

Поиск
Список
Период
Сортировка
От apz
Тема Re: Self Join Help
Дата
Msg-id 3EA0F16E.2040408@nofate.com
обсуждение исходный текст
Ответ на Re: Self Join Help  (apz <apz@nofate.com>)
Ответы Re: Self Join Help  (Gerard Samuel <gsam@trini0.org>)
Список pgsql-php
this is second time I post to a forum, and second time I correct
myself... ugh, I should delay posting by 15 minutes, or stop re-reading
my emails after posting... ;D

anyways:

apz wrote:
> test=# select a.topicname as parent, b.topicname as child from topics as
> a left join topics as b on a.id = b.pid;
>
>  parent |   child
> --------+------------
>  XHTML  | null
>  Foo    | null
>  Apache | PHP
>  News   | Tech News
>  News   | World News

this actually should return:


test=# select a.topicname as parent, b.topicname as child from topics as
a left join topics as b on a.id = b.pid;

  parent     | child
------------+------------
  XHTML      | null
  Foo        | null
  Apache     | PHP
  News       | Tech News
  News       | World News
  PHP        | null
  Tech News  | null
  World News | null


the querry with left join should return child=null if a node is a leaf.
so XHTML and PHP return child as null because neither have any nodes
underneath.
this also should mean that topicname should not allow null values, not
to confuse ourselves further on.

so two ways are:
  - add one node which is always root, use your querry
  - use left join, when no child then child returns as null



/apz,  You can always tell luck from ability by its duration.


В списке pgsql-php по дате отправления:

Предыдущее
От: apz
Дата:
Сообщение: Re: Self Join Help
Следующее
От: "Adrian Tineo"
Дата:
Сообщение: Re: session_pgsql-0.6.1