I got something like this table:
id | code | code_parent |
----|---------|------------ |
1 | 1 | 1 |
2 | 2 | 2 |
3 | 3 | 1 |
4 | 4 | 3 |
5 | 5 | 2 |
6 | 6 | 4 |
7 | 7 | 6 |
I want to return a list with all the parents. Example:
select * from table where code 7
I would like the return like this:
{1,3,4,6}
Thanks for any help.