Sir, Joe Celko's 'SQL For Smarties' has two chapters devoted to tree 
problems. After a quick look in the book, it appears to me that you 
can use one of his algorithms if you restructure your table and adapt 
his SQL to the MySQL dialect.  See the chapter on Nested Set Models.

Bob Hall

>Hi,
>
>I have a recursive Problem. I have a Table with columns "id", "name" and
>"pid". E.g:
>
>name1
>   name11
>   name12
>     name121
>     name122
>   name13
>name2
>   name21
>
>In the Table it would look like:
>
>id, name, pid
>1  name1   0
>2  name11  1
>3  name12  1
>4  name121 3
>5  name122 3
>6  name13  1
>7  name2   0
>8  name21  7
>
>Is there any select statement, which give me the path e.g to the id 5?
>I want to provide the 5 and will get the following:
>
>id5 (pid3) -> id3 (pid1) -> id1 (pid0)
>
>name122 -> name12 -> name1
>
>Do you have any idea?
>
>Oliver
>
>
>--
>[EMAIL PROTECTED] * [EMAIL PROTECTED] * [EMAIL PROTECTED] * [EMAIL PROTECTED]
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail 
><[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Know thyself? Absurd direction!
Bubbles bear no introspection.     -Khushhal Khan Khatak

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to