There is a table Categories, type

id slug tree 

As a single request, you can first select a category where slug (this is understandable), and then from the table found from this table, select everything where tree = sample by slug, i.e. in two requests it is like this

 $category = SELECT * FROM category WHERE slug $children = SELECT * FROM category WHERE tree = $category->id 

How about one?

    2 answers 2

    There may be a problem if multiple elements are returned in the subquery, in this case it is more appropriate to use in :

     $children = SELECT c.* FROM category c WHERE c.tree in (SELECT id FROM category WHERE slug) 
    • Thanks, now I will know. - Guest
     $children = SELECT * FROM category WHERE tree = (SELECT id FROM category WHERE slug) 

    Will not work?

    • I think fit, thanks. - Guest