How to generate the order if you know the next item for each item?

Поиск
Список
Период
Сортировка
Искать
От
Rockdale Green
Тема
How to generate the order if you know the next item for each item?
Дата
Msg-id
CAArxxWj=_gc=6RL0QGPzpbXMLZTvxDOqG-sQVxbpCmVu5Q2jpQ@mail.gmail.com
Список
Дерево обсуждения
How to generate the order if you know the next item for each item? Rockdale Green <rockdale.green@gmail.com>
Re: How to generate the order if you know the next item for each item? "David G. Johnston" <david.g.johnston@gmail.com>
Re: How to generate the order if you know the next item for each item? Rockdale Green <rockdale.green@gmail.com>
Re: How to generate the order if you know the next item for each item? Tony Shelver <tshelver@gmail.com>
Re: How to generate the order if you know the next item for each item? Rockdale Green <rockdale.green@gmail.com>
Hi, all:

I have two tables one is a lookup for all the tasks, another table stores the next task for each task, I want to generate a list of tasks with its sequence number, can I do it in one query? 

Table task

id  name 
1   postoffice
2   grocery store
3.  walk dog
4.  swimming 
5   roller skate
7   biking


table next_task

task   next_task
3         7
7         1
1          4
4          2
2          5

and I want to get the list in order 

task                task_order 
3 (walk dog)              1
7 (biking)                   2
1 (postoffice)             3  
4 (swimming)             4
2 (growcery store)      5
5 (roller skate)            6

It might be just very simple and I have tried but somehow I am blocked. 

Thanks in advance
-Rockdale 


В списке pgsql-sql по дате отправления
От: Steve Midgley
Дата:
От: David G. Johnston
Дата:
FAQ