开发者

How do you get the index of a node in a left-right tree?

开发者 https://www.devze.com 2023-01-26 06:44 出处:网络
I have left-right trees in my database which are a problem for performance. I\'ll switch to a system with a parentId and an orderId.

I have left-right trees in my database which are a problem for performance. I'll switch to a system with a parentId and an orderId.

I'm looking for a sql script that ca开发者_高级运维n give me the index of a node in a left-right tree.


Like this?

select COUNT(treestructureid) 
from TreeStructures s,
(select leftvalue, rightvalue, treeid, ParentTreeStructureId from TreeStructures where TreeStructures.TreeStructureId = 204260)
as data
where s.LeftValue <= data.LeftValue and s.RightValue <= data.RightValue
and s.TreeId = data.TreeId and s.ParentTreeStructureId = data.ParentTreeStructureId
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号