sqlpostgresqlselectwhere-clauseltree

PostgreSQL ltree find all child node of a given path (With out using expression)


Only child node of given path (Except the given path)

Query:

select path from tree where path <@ 'a.b.c';

Result:

enter image description here

Expected result:

All the below node of a.b.c (In result don't needed a.b.c)


Solution

  • How about explicitly excluding the exact value?

    select path 
    from tree 
    where path <@ 'a.b.c' and path <> 'a.b.c'