Getting all parent rows in one SQL query

后端 未结 7 2010
温柔的废话
温柔的废话 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:21

    I think, there's no easy way to do that, using one query.

    I would recommend to take a look at Nested Sets, that seems to fit your needs.

提交回复
热议问题