prod.php - L-29 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 product_id) t2 ON (t1.id=t2.product_id) ' at line 19 SQL:SELECT id, name, LOWER(name) as name2, unit1 unit_name, category_id as cat_id, category_id as grp_id, num as code, (SELECT name FROM dic_prod_category WHERE id=category_id) as cat_name, (SELECT name FROM dic_prod_category WHERE id=category_id) as grp_name, ROUND(IFNULL(t2.ost,0),2) as ost, 0 as ost2, IFNULL(t1.price1/coeff,0)*0.0 as price, IFNULL(t1.price2/coeff,0)*0.0 as price2, IFNULL(t1.price3/coeff,0)*0.0 as price3, IFNULL(t1.price4/coeff,0)*0.0 as price4, IFNULL(t1.price1/coeff,0)*0.0 as in_price, 0.0 as price5, 0.0 as price6, 0 as discount_type, 0 as not_discount, IFNULL(coeff,1) as coeff, num as inc_search, 0 as har_soni FROM dic_products t1 LEFT JOIN (SELECT product_id, SUM(qty) as ost FROM trs_whmove WHERE wh_id= GROUP BY product_id) t2 ON (t1.id=t2.product_id) ORDER BY cat_name, grp_name, name;