recursive query, store path MySQL

Hi,

I have a table with two columns

'parentid' 'productref'

the 'parentid' column path always starts at '0' and follows a tree structure, so parentid can have a path '0' '3' '67' '4567'

currently only the final parentid is stored.
I would like a query that would find the path and output something like:

'productref' 'parentpath'

1234            0|3|67|4567

Any suggestions?
Thanks
Tony PearceAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
while you can do this in MS SQL and oracle easily, not so easy to crack in MySQL.

you should read up this page which discusses the options you have, starting with how to store the data:
http://dev.mysql.com/tech-resources/articles/hierarchical-data.html
0
 
Tony PearceAuthor Commented:
Great, thanks, that has provided exactly what I was looking for.
0
All Courses

From novice to tech pro — start learning today.