Upward recursion and downward recursion in 3.sql

Source: Internet
Author: User

1. Recursive down

SELECT * FROM table_name where condition connect by prior BMBM (This level association condition) =SJBMBM (Parent association condition ) Start with BMBM (This level association condition) = ' 610000000 000 ' (This level encoding)--includes this level

SELECT * FROM table_name where condition connect by prior BMBM (This level association condition) =SJBMBM (Parent association condition ) Start with SJBMBM (This level association condition) = ' 6100000 00000 ' (This level encoding)--does not include this level

2. Recursion Upward

SELECT * FROM table_name where condition connect by prior SJBMBM (Parent association condition) =BMBM (This level association condition) Start with BMBM (This level association condition) = ' 610528000 000 ' (This level encoding)--includes this level

SELECT * FROM table_name where condition connect by prior SJBMBM (Parent association condition) =BMBM (This level association condition) Start with SJBMBM (This level association condition) = ' 6105280 00000 ' (This level encoding)--Includes subordinates

Note: The difference between upward recursion and downward recursion lies in the difference in the order of the Intermediate association conditions, noting that the meaning of the start with condition is also different.

Upward recursion and downward recursion in 3.sql

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.