Hierarchical data - Get tree of single item in MySQL hierachircal database

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I want to retrieve the path to a single node in a hierachical database where only the parent node ID is stored as a reference. Could someone give me a query or some advice on how to write a query (ideally the first option - I m a MySQL noob) so that all the node titles in the end node s path are given in a generated table?

id   name          depth
10   Top level     0
22   Second level  1
34   3rd level     2
43   End node      3

I want to use this data to create on of those "you are here" lists like:

Home > Forums > Stuffs > ... > Topics

Thanks for any help,

James

Answers

This is only possible for a fixed number of levels, as there is no recursion in SQL.

http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/ http://mikehillyer.com/articles/managing-hierarchical-data-in-mysql/

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/4171959/get-tree-of-single-item-in-mysql-hierachircal-database

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils