Err No : 1064, detail : 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 p.product_id ORDER BY p.modified_date DESC' at line 9 SELECT p.*, c.category_id, c.category_name, b.brand_name, c.uri AS category_uri, b.official_site FROM products p LEFT JOIN product_categories pc ON pc.product_id=p.product_id LEFT JOIN brands b ON b.brand_id=p.brand_id LEFT JOIN categories c ON c.category_id=pc.category_id LEFT JOIN users u ON u.user_id=c.modified_by WHERE p.product_id= GROUP BY p.product_id ORDER BY p.modified_date DESC