本文介绍了自引用表 (Oracle) 上的 SQL 递归查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!
问题描述
假设我有这个样本数据:
Lets assume I have this sample data:
我想选择从 accountId = 1 开始的所有记录,所以预期的结果是:
I would like to select all records start from accountId = 1, so the expected result would be:
我目前能够进行递归选择,但是我无法从父引用访问数据,因此我无法返回 parent_name.我使用的代码是(适用于简单的例子):
I am currently able to make the recursive select, but then I can't access the data from the parent reference, hence I can't return parent_name. The code I'm using is (adapted to the simplistic example):
我应该使用什么 SQL 来进行上述检索?
What SQL should I be using to the mentioned above retrieval?
未来搜索者的额外关键词:SQL 选择由同一个表中的父键表示的分层数据
推荐答案
使用:
这篇关于自引用表 (Oracle) 上的 SQL 递归查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!
本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!