SELECT node.page_id, node.link_text, node.link_alt_text, node.parameters, node.ext_url, node.desc, node.on_top_menu_bar, node.on_footer_bar, node.lft, node.rght, node.int_page_filename, node.title, specials.name, node.section_id, section.name as sectionName, (COUNT( parent.title ) -1) AS depth FROM pages AS node NATURAL JOIN specials LEFT JOIN section USING (section_id), pages AS parent WHERE (node.lft BETWEEN parent.lft AND parent.rght) AND node.section_id = 1 GROUP BY node.page_id HAVING depth < 1 ORDER BY node.lft