Forum Moderators: open

Message Too Old, No Replies

postgres parent/child in on table

         

brnco

11:01 pm on Feb 8, 2008 (gmt 0)

10+ Year Member



I have a table like:

id ¦ name ¦ id_parent ¦ id_child
1 ¦ Team Lead ¦ 10 ¦ 0
2 ¦ Senio Prg ¦ 20 ¦ 10
3 ¦ Call centre ¦ 30 ¦ 20
4 ¦ Programmer ¦ 40 ¦ 10

etc...

I would like to make a select that will order the data same way as left join. That means: Below Team Lead should be Senio Prg and Programmer.

id_child rows will be always below id_parent

Can you help me with this please? I know how to solve it with 2 Select statements but I don't think it's the most comfortable way.

Thanks in advance

ZydoSEO

10:08 pm on Feb 9, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It would help if you would explain the purpose of the fields in your table. I have no clue what the data represents. Where do you get the values in id_parent and id_child? Are those other 'id' values from this same table?

It would also help if you showed what order the rows should be output in by the query you are requesting.