SELECT c.*, count(p.id) AS pcount FROM categories c LEFT JOIN products p ON p.category_id = c.id WHERE c.parent_id IS NULL GROUP BY c.id ORDER BY c.priority DESC,c.name ASC [nativecode=1146 ** Table 'mag.categories' doesn't exist]