Skip to content
Advertisement

Tag: recursive-query

MySQL – Recursively list all parents and ancestors of all items in table

I have a table with a parent/child hierarchy that supports multiple (theoretically infinite) levels of nesting: I am trying to build a query that produces a concatenated list of every item’s parent items up until the highest parent in the tree: Based on a number of other answers here I have constructed the following MySQL query: See Fiddle here: http://sqlfiddle.com/#!9/48d276f/902/0

Advertisement