分类文章

热门文章

oracle 树状查询 connect by prior start with

connect by prior start with 经常会被用到一个表中存在递归关系的时候。比如我们经常会将一个比较复杂的目录树存储到一个表中。或者将一些部门存储到一个表中,而这些部门互相有隶属关系。这个时候你就会用到connect by prior start with。

比如说我想查询组织表中组织id为10000的所有下级组织的记录

1
SELECT * FROM t_org connect BY prior org_id = owner_id start WITH org_id = 10000;

就是这么简单

随机文章



分享生活也赚钱,赶快加入吧

Loading…

相关文章:

  1. oracle add_months函数
  2. oracle 合并列数据

请给本文打分   
1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 3.00 out of 5)
Loading ... Loading ...

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="">

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word