0

假设我想查找“活动”食谱的 ltree 路径,然后使用这些路径查找这些食谱的后代。

# recipes
name      | category | path
-------------------------
Main        active     recipeA
Sides       inactive   recipeB
Lettuce     active     recipeC
Drinks      inactive   recipeD
abc                    recipeA.tacos
def                    recipeA.hamburgers
ghi                    recipeB.sausages
jkl                    recipeC.lettuce
mno                    recipeC.fries
pqr                    recipeD.cola

这是我的伪代码查询(这显然是不正确的):

SELECT name, category, path FROM recipes WHERE category='active'......then SELECT name, path FROM recipes WHERE path <@ '(IDENTIFIED|RECIPE|PATHS|HERE)'

结果将为我提供以下路径的记录:

abc         recipeA.tacos
def         recipeA.hamburgers
jkl         recipeC.lettuce
mno         recipeC.fries

有没有办法在一个查询中正确地做到这一点?

4

0 回答 0