Arno Kuhl wrote: > Not strictly a php issue but it's for a php app, hope that counts > (plus I haven't had much joy googling this) > > 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? > Or do I have to iterate selecting each parent record while parentid> > 0 and build the list entry by entry?
Little difficult to answer what you don't say what you are using as a database. Recursive queries are now possible on many databases, except I think for MySQL. I run this type of query all the time on Firebird and Postgres now supports the same CTE functions. -- Lester Caine - G8HFL ----------------------------- I'm currently using MySQL but I'll switch databases if there's a compelling reason and no drawbacks. Thanks for the lead, I'm googling recursive queries. Cheers Arno -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php