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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Guy Hengel [angelIII / a3]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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tony PearceAuthor Commented:
Great, thanks, that has provided exactly what I was looking for.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.