Get the App
SLTechnology News&Howtos  ›  Database  › 

How to query all the last nodes in the Sql tree structure table

Shulou Source: shulou.com Published: 2022-05-31 17:47:39 10月03日 Update

This article mainly explains "how to query all the last nodes in the Sql tree structure table". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to query all the last nodes in the Sql tree structure table.

Goal: show all last-level nodes

Train of thought:

Judge whether there are child nodes according to the number of count of the parent node

Source code sql

Select t. "CLASS_CODE", t. "CLASS_NAME", t. "FATHER_CLASS_CODE", t. "CLASS_STATE", t. "OP_USER", t. "OP_TIME", t. "IS_PROJECT", nvl (t2.isParentPhen0) isParent from FSS_PROJECT_CLASS t LEFT JOIN (SELECT count (1) isParent,FATHER_CLASS_CODE from FSS_PROJECT_CLASS GROUP BY FATHER_CLASS_CODE) t2on t.CLASS_CODE = T2.FATHER_CLASS_CODE

According to isParent, all the last nodes can be judged.

Where isParent=0

Just ok.

At this point, I believe that everyone on the "Sql tree structure table how to query all the last nodes" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Nodes queries structure content learning practical deeper interest practicality practicality ideas simple operation methods more friends source code targets websites channels t. Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Microsoft vpn Huawei OPPO Reno