我想在 postgresql 中获取 2 级后代。下面的 Query 工作正常,它正在返回 Path = '103' 的下一级后代
SELECT * FROM TABle WHERE path ~ ( ( ( '103' ) || '.*{2}' )::lquery )
但是问题是我没有 where 条件的路径值。我有代码值,我需要从该代码值获取路径,然后返回下一个 2 级后代。
我尝试使用以下查询,但这给出了语法错误
select * from TABLE where path ~ ( ( (
**(Select path from table where code like 'test')**
) || '.*{1}' )::lquery )
有没有办法使用子查询来获取路径