Getting all parent rows in one SQL query

后端 未结 7 1980
温柔的废话
温柔的废话 2020-11-27 11:59

I have a simple MySQL table thats contains a list of categories, level is determined by parent_id:

id  name    parent_id
---------------------------
1   Home         


        
7条回答
  •  無奈伤痛
    2020-11-27 12:15

    AFAIK no.

    This Sitepoint article may help you.

    You could retrieve all the elements with one query, store it in an array and then iterate, as explained here and here

提交回复
热议问题