A Database Error Occurred

Error Number: 1064

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 'products_categories AS pc LEFT JOIN categories node ON pc.c' at line 6

SELECT /* categories_model->nested_list() */ p.id as product_id, p.popularity, (SELECT IF(SUM(ps.amount), 1, 0) FROM product_supplies ps WHERE ps.amount > 0 AND ps.cost_price > 0 AND ps.product_id = p.id AND (modification_id = 0 OR EXISTS (SELECT 1 FROM modifications m WHERE ps.product_id = m.product_id AND ps.modification_id = m.id)) GROUP BY ps.product_id) in_stock FROM products AS p products_categories AS pc LEFT JOIN categories node ON pc.category_id = node.id, categories AS parent WHERE node.lft >= parent.lft AND node.rgt <= parent.rgt AND parent.id = '372' AND p.status = 'active' AND pc.product_id = p.id AND p.sell_price > 0 GROUP BY p.id ORDER BY in_stock DESC, p.popularity DESC LIMIT 10