用H2 DB和SQL递归路径
我有以下常见形式的路径名(路径深度不限):
/a/a/b/c/d/e/...
示例
/a/b/c/d/e
预期结果
我现在想实现的目标是将路径拆分为包含文件夹和各个父的表
parent | : |
---|---|
/ C/D/ | E |
/A/B/C/ | D |
/A/B/ | C |
/A/ | B |
/ | A |
在分裂字符串方面,H2 DB的功能受到限制,因此我的假设是必须解决的。递归(尤其是因为路径深度不受限制)。
任何帮助将不胜感激:)
I've path names of the following common form (path depth not limited):
/a/b/c/d/e/...
Example
/a/b/c/d/e
Expected result
What I'd like to achieve now is to split the path into a table containing the folder and the respective parent:
parent | folder |
---|---|
/a/b/c/d/ | e |
/a/b/c/ | d |
/a/b/ | c |
/a/ | b |
/ | a |
The capabilities of the H2 db are a bit limited when it comes to splitting strings, thus my assumption was it must be solved recursively (especially since the path depth is not limited).
Any help would be appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要使用递归查询,例如:
它生成
You need to use a recursive query, for example:
It produces
做类似的事情:
导致您
不确定您是否对Tailt
/
字符真的感兴趣,但是您可以根据需要轻松修复查询。Do something like this:
resulting in
Not sure if you're really interested in trailing
/
characters, but you can easily fix the query according to your needs.