本文介绍了分层查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 各位大家好! 有人知道如何为postgresql构建分层查询吗? 我有一张带树的表格(id,parent) 并且需要找到从树的任何一点到任何其他点的方式。 我想要列出所有步骤来自点A到点B 对每一步进行一些更改(这是algorythm要求的)。 这是一个例子: treetable(存储树的地方): id父数据 int4 int4 varchar(255) 0 0 root 1 0 root'的chield 1 2 0 root'的chield 2 3 1 root'的chield 1 chield 1 4 1 root'的chield 1 chield 2 5 2 root'的chield 2 chield 1 6 2 root''s chield 2 chield 2 我想得到一些李ke this: 起点root的chield 2 chield 2" 完成" root'的chield 1 chield 1" 我需要的结果: id父数据 6 2 root'的chield 2 chield 2 2 0 root's chield 2 0 0 root 1 0 root's chield 1 4 1 root''s chield 1 chield 2 i知道在甲骨文有可能但是postgres呢? 祝你好运, Anton Nikiforov ---------------------------(播出结束)--------- ------------------ 提示7:别忘了增加你的免费空间地图设置Hello everybody!Does someone know how to build hierarchical queries to the postgresql?I have a table with tree in it (id, parent)and need to find a way from any point of the tree to any other point.And i would like to have a list of all steps from point A to point Bto make some changes on each step (this is required by the algorythm).Here is an example:treetable (where tree is stored):id parent dataint4 int4 varchar(255)0 0 root1 0 root''s chield 12 0 root''s chield 23 1 root''s chield 1 chield 14 1 root''s chield 1 chield 25 2 root''s chield 2 chield 16 2 root''s chield 2 chield 2And i want to get something like this:start point "root''s chield 2 chield 2"finish "root''s chield 1 chield 1"And the result i need:id parent data6 2 root''s chield 2 chield 22 0 root''s chield 20 0 root1 0 root''s chield 14 1 root''s chield 1 chield 2i know that it is possible in Oracle but what about postgres?Best regards,Anton Nikiforov---------------------------(end of broadcast)---------------------------TIP 7: don''t forget to increase your free space map settings推荐答案 -------------------- Andrew Rawnsley 总统 雷文斯菲尔德数字资源集团有限公司 (740)587-0114 www.ravensfield.com ----------- ----------------(广播结束)--------------------------- 提示4:不要杀死-9''邮政局长--------------------Andrew RawnsleyPresidentThe Ravensfield Digital Resource Group, Ltd.(740) 587-0114 www.ravensfield.com---------------------------(end of broadcast)---------------------------TIP 4: Don''t ''kill -9'' the postmaster 我相信我看到关于源的补丁的关于新鲜肉的公告 允许Oracle式连接。是的: http://gppl.terminal.ru/index。 eng.html 我本可以发誓在contrib /中也有一些东西,但我现在看不到它了。现在。 - Richard Huxton Archonet Ltd ----- ----------------------(播出结束)----------------------- ---- 提示6:您是否搜索了我们的列表档案? http://archives.postgresql.orgI believe I saw an announcement on freshmeat about a patch for the source toallow Oracle-style connect by. Yep: http://gppl.terminal.ru/index.eng.htmlI could have sworn there was something in contrib/ too, but I can''t see itnow.--Richard HuxtonArchonet Ltd---------------------------(end of broadcast)---------------------------TIP 6: Have you searched our list archives? http://archives.postgresql.org 问候, Oleg __________________________________________________ ___________ Oleg Bartunov,sci.researcher,AstroNet的主持人, Sternberg天文学院,莫斯科大学(俄罗斯) 互联网: ol ** @ sai.msu.su , HTTP ://www.sai.msu.su/~megera/ 电话:+007(095)939-16-83,+ 007(095)939-23-83 ---------------------------(广播结束)------- -------------------- 提示1:订阅和取消订阅命令转到 ma ******* @ postgresql.orgRegards,Oleg__________________________________________________ ___________Oleg Bartunov, sci.researcher, hostmaster of AstroNet,Sternberg Astronomical Institute, Moscow University (Russia)Internet: ol**@sai.msu.su, http://www.sai.msu.su/~megera/phone: +007(095)939-16-83, +007(095)939-23-83---------------------------(end of broadcast)---------------------------TIP 1: subscribe and unsubscribe commands go to ma*******@postgresql.org 这篇关于分层查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-28 17:34