【问题标题】:PostgreSQL ltree find all child node of a given path (With out using expression)PostgreSQL ltree 查找给定路径的所有子节点(不使用表达式)
【发布时间】:2020-10-12 15:31:03
【问题描述】:

给定路径的唯一子节点(给定路径除外)

查询:

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

结果:

预期结果:

a.b.c 的所有以下节点(结果不需要 a.b.c)

【问题讨论】:

  • path的数据类型是什么?
  • 是 ltree 类型

标签: sql postgresql select where-clause ltree


【解决方案1】:

明确排除确切的值怎么样?

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

【讨论】:

  • 谢谢,得到了预期的结果
【解决方案2】:

或者,您可以使用:

select path 
from tree
where path ~ 'a.b.c.*{1}'

【讨论】:

    猜你喜欢
    • 2015-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-03-07
    相关资源
    最近更新 更多