List:General Discussion« Previous MessageNext Message »
From:Gleb Paharenko Date:January 30 2006 1:04pm
Subject:Re: display a hierarchic tree
View as plain text  
Hello.

This is not an exact answer on your question, however it could be
interesting for you:
  http://dev.mysql.com/tech-resources/articles/hierarchical-data.html

Jochen Kaechelin wrote:
> I have the following table:
> 
> mysql> select * from link_categories;
> +----+-------+-------------+---------------+-----------+---------+
> | id | level | category_id | category      | parent_id | deleted |
> +----+-------+-------------+---------------+-----------+---------+
> |  1 |     1 |        1000 | Software      |         0 |       0 |
> |  2 |     1 |        2000 | Harware       |         0 |       0 |
> |  3 |     2 |        1001 | Virenscanner  |      1000 |       0 |
> |  4 |     2 |        1003 | Packprogramme |      1000 |       0 |
> |  5 |     3 |        1004 | Linux         |      1001 |       0 |
> |  6 |     3 |        1005 | Windows       |      1001 |       0 |
> |  7 |     4 |        1006 | Windows XP    |      1005 |       0 |
> |  8 |     2 |        1007 | Sniffer       |      1000 |       0 |
> |  9 |     4 |        1008 | Debian Woody  |      1004 |       0 |
> | 10 |     1 |      100000 | Vermischtes   |         0 |       0 |
> +----+-------+-------------+---------------+-----------+---------+
> 10 rows in set (0.24 sec)
> 
> and I want to display a tree like:
> 
> 	Software
> 	   Virenscanner
> 	     Linux
>                Debian Woody
>              Windows
>                Windowsd XP
> 	   Packprogramm
>            Sniffer
> 	Hardware
> 	Vermischtes
> 	....
> 
> Can someone give me hint how to build a query?
> 
> I run MySQL 4.1.x and 5.0.x and I use PHP.
> 
> Thanx.
> 


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   Gleb.Paharenko@stripped
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com
Thread
display a hierarchic treeJochen Kaechelin29 Jan
  • Re: display a hierarchic treePeter Brawley29 Jan
  • Re: display a hierarchic treemysql29 Jan
  • Re: display a hierarchic treeGleb Paharenko30 Jan
    • Finding the row number satisfying a conditon in a result setJacques Brignon30 Jan
      • Re: Finding the row number satisfying a conditon in a result setJake Peavy30 Jan
    • Re: display a hierarchic tree(Pete Harlan)30 Jan