I have a table in postgresql that contains:
id name arrayofparents
1 First
2 Second {1}
3 Second_Sec {1,2}
4 Third {1,2,3}
5 Second_A {1}
6 Other
7 Trash {6}
arrayofparents is of type integer[] it contains a list of the parents records for that row with the correct order.
id=4 parents are: First then Second then Second_sec
How do I write a query that for any given id it will generate a string of it's parents name?
for example:
id=3: First->Second.
id=4: First->Second->Second_sec.
id=7: Other.

Check Solution