Full path of hierarchical Oracle query: sys_connect_by_path

Source: Internet
Author: User

In the morning, the customer needs to export the full path of some records and records in the category (for example, table A is the master table, table B is the category, and a foreign key sort_id is associated with B, B In addition to the ID and parent_id), I tried a little bit and got it out. Record it:

PS: kbs_entry can be viewed as Table A mentioned above, and kbs_sort is table B.

Select Replace (replace (A. article_or_point,'s ', 'campaign'), 'A ','Article') As property, C. path as Directory,. subject as title from (select B. ID, ltrim (max (sys_connect_by_path (B. name, '->'), '->') as path from kbs_sort B connect by B. parent_id = prior B. id group by ID) C, kbs_entry A where. sort_id = C. ID and (. article_or_point = 'A' or. article_or_point ='s ')

According to the format requirements of the customer, the attribute of article_or_point = 'A' is called an article, and the attribute of S is called a promotion activity, so it looks complicated.

Related Article

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.