木有看懂,求指点 http://threebit.net/tutorials/nestedset/tutorial1.html
For example, below you can see the following:
Now, that being said the selection of all nodes in an arbitrarily deep nest is done very simply. Generally, this query will be used to feed some other query's in clause or as a constraint for a DML statement.
SELECT
n0.nid
FROM
NestedSet n0,
NestedSet n1
WHERE
n1.nid = 0
AND n0.lft BETWEEN n1.lft AND n1.rft;
从 sql 看这是一个自关联,难点在 lft 和 rft 这 2 个字段。 通过 lft 和 rft 缩小查询子集,从而达到快速查询的目的。不断的把当前集合变成 n 个嵌入子集,难怪说它有性能优势