Mysql
 sql >> Base de Dados >  >> RDS >> Mysql

Árvore de pré-encomenda modificada do MySql para criar url


Algo assim deve bastar...
SELECT CONCAT_WS('/',x.path,y.page_name) full_path
  FROM
     ( SELECT node.id, GROUP_CONCAT(parent.title ORDER BY parent.lft SEPARATOR '/') path
         FROM category node
         JOIN category parent
           ON node.lft BETWEEN parent.lft AND parent.rgt
        GROUP 
           BY node.title
        ORDER 
           BY node.lft
     ) x
  JOIN pages y
    ON y.category_id = x.id;