SELECT p.*, count(p1.id) AS pcount FROM pages p LEFT JOIN pages p1 ON p1.parent_id = p.id AND p1.lang_id = 3 WHERE p.parent_id IS NULL AND p.lang_id = 3 GROUP BY p.id ORDER BY p.priority [nativecode=1030 ** Got error 28 from storage engine]