MYSQL output in tree format OR Adding level (Parent-Child)

后端 未结 4 1877
失恋的感觉
失恋的感觉 2020-12-19 21:25

Below is what I have in my table.

myTable

++++++++++++++++++++
Parent   +  Child
++++++++++++++++++++
  C1     +    G1
  C1     +    G2
  C1     +          


        
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-19 22:10

    MySQL and RDBMS's in general are not great at this sort of structure. You'll probably have to use client-side recursion to do this.

    If the recursion is limited to just three deep, like your example, you can do it with joins, but it's not very scalable for deeper trees.

提交回复
热议问题