- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'GROUP by c.id ORDER by c.theorder' at line 3
SELECT c.id FROM categories as c JOIN prod_cat_map ON prod_cat_map.cat_id = c.id JOIN products ON products.id = prod_cat_map.prod_id JOIN variants ON variants.product_id = products.id WHERE parent_id = GROUP by c.id ORDER by c.theorder;