SELECT *, (GROUP_CONCAT(`Parent`.`key` ORDER BY `Parent`.`lft` ASC SEPARATOR '.')) AS `Setting__path`, `Setting`.`id` FROM `akademie`.`settings` AS `Setting` LEFT JOIN `akademie`.`settings` AS `Parent` ON (`Parent`.`lft` <= `Setting`.`lft` AND `Parent`.`rght` >= `Setting`.`rght`) WHERE 1 = 1 GROUP BY `Setting`.`id`