I have a table with an LTREE
column, and the data is somewhat as described below.
ID Label Path
1. ABC. 1
2. DEF. 1.2
26. GHI. 1.2.26
Let's suppose I want to find all the ancestors of the node labelled GHI
. The query I'm using is
SELECT *
FROM
my_table as tbl
WHERE
tbl.path @> (
SELECT
path
FROM
my_table
WHERE
id=26
)
However, this returns only the last row, whereas I want all the three rows. What am I doing wrong?