I'm using MySql with PHP and have all my data in a table like this:
"id" "name" "description" "level" "parent" "country" "maxLevel"
"1" "Kitchenware" "Kitchenware description" "1" "0" "US" "0"
"2" "Knives" "All our knives" "2" "1" "US" "0"
"3" "Butter Knives" "All Butter Knives" "3" "2" "US" "0"
"4" "Cut em all" "Cut em all" "4" "3" "US" "0"
"5" "Cull em all" "Cull em all" "4" "3" "US" "0"
"6" "Smear em all" "Smear em all" "4" "3" "US" "0"
"7" "Meat Knives" "All Meat Knives" "3" "2" "US" "0"
"8" "Cut em meat" "Cut em meat" "4" "7" "US" "0"
"9" "Cull em meat" "Cull em meat" "4" "7" "US" "0"
"10" "Smear em meat" "Smear em meat" "4" "7" "US" "0"
From this, If I had for eg: id = 10, how would the sql be to display the hierarchy for an item?
So for id = 10, the hierarchy would be:
Kitchenware > Knives > Meat Knives > Smear em meat
For id=7 the hierrchy would be:
Kitchenware > Knives > Meat Knives
For id=4 the hierarchy would be
Kitchenware > Knives > Butter Knives > Cut em all
And so on. Any idea how to structure the sql to achieve this?