Unix Technical Forum

hierarchical problem

This is a discussion on hierarchical problem within the MySQL forums, part of the Database Server Software category; --> Hi ! I've a problem, I have a table "messages" with 3 fields : "id","name","parent" parent can be NULL ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 03-28-2008, 04:41 AM
sebastien.ramage@gmail.com
 
Posts: n/a
Default hierarchical problem

Hi !

I've a problem, I have a table "messages" with 3 fields :
"id","name","parent"
parent can be NULL or a id number

example :
id | name | parent
1 | toto | NULL
2 | titi | NULL
3 | test | 2
4 | new | NULL
5 | other | 3
6 | blabla | 4

I want to get a hierarchical list like this

1 toto
2 titi
-> 3 test
-> 5 other
4 new
-> 6 blabla

Is it possible ? directly from mysql or by using some php?

thank you


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-28-2008, 04:41 AM
Rik Wasmus
 
Posts: n/a
Default Re: hierarchical problem

On Thu, 27 Mar 2008 15:46:58 +0100, sebastien.ramage@gmail.com
<sebastien.ramage@gmail.com> wrote:

> Hi !
>
> I've a problem, I have a table "messages" with 3 fields :
> "id","name","parent"
> parent can be NULL or a id number
>
> example :
> id | name | parent
> 1 | toto | NULL
> 2 | titi | NULL
> 3 | test | 2
> 4 | new | NULL
> 5 | other | 3
> 6 | blabla | 4
>
> I want to get a hierarchical list like this
>
> 1 toto
> 2 titi
> -> 3 test
> -> 5 other
> 4 new
> -> 6 blabla
>
> Is it possible ? directly from mysql or by using some php?


http://dev.mysql.com/tech-resources/...ical-data.html
--
Rik Wasmus
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-28-2008, 04:41 AM
sebastien.ramage@gmail.com
 
Posts: n/a
Default Re: hierarchical problem


>
> http://dev.mysql.com/tech-resources/...ical-data.html
> --
> Rik Wasmus


yes i have saw that but I cannot make working my example...

I need more explanation
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-28-2008, 04:41 AM
Rik Wasmus
 
Posts: n/a
Default Re: hierarchical problem

On Thu, 27 Mar 2008 19:40:12 +0100, sebastien.ramage@gmail.com
<sebastien.ramage@gmail.com> wrote:
>> http://dev.mysql.com/tech-resources/...ical-data.html

>
> yes i have saw that but I cannot make working my example...
>
> I need more explanation


With some minor alterations you can use the 'Retrieving a Full Tree'
example from the Adjacancy Model, the limitations of the Adjacency Model
are explained there.
--
Rik Wasmus
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 03:06 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com