SELECT p.*, count(p1.id) AS pcount FROM pages p LEFT JOIN pages p1 ON p1.parent_id = p.id WHERE p.parent_id=91 GROUP BY p.id ORDER BY p.priority [nativecode=2013 ** Lost connection to MySQL server during query]