Re: Listing parent ids

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



""Arno Kuhl"" <arno@xxxxxxxxxxxxxx> wrote in message 
news:487F03135D2B452B89F22C95E278C7D4@point01...
>
> I have a table with an id and a parentid.
> If it's a top-level record the parentid is 0, otherwise it points to 
> another
> record, and if that record isn't a top-level record its parentid points to
> another record, etc (a linked list).
>
> Is there a single select that will return the complete list of parentids?

You say you have a parentid and an id - ie, two specific fields in your 
records.  You say that you want to query all the parentids.  Nobody else has 
said this, but why not just

Select unique ids where parentid=0  ?  That gives you (as you say) all your 
top-level records, which are the parents of everything, no?  Or are you 
looking for each id that is itself a parent to something else?  If the 
latter, then why not
  select unique parentid where parentid <> 0  ? 



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux