Query for categories failed SELECT category.id, category.name, category.position, pages.icon, MAX(pages.id) as mocid, COUNT(pages.id) as size FROM category, pages WHERE category.personid=79498r AND pages.categoryid=category.id AND visible<>0 GROUP BY category.id ORDER BY category.position