ERROR: select distinct p2c.products_id as products_id , if(find_in_set(manufacturers_id, '97,92,87,41,118,209,286,322,8' ),1,0) AS top_mfg_sort, if(locate('11',GROUP_CONCAT( DISTINCT p2f.flag_id )),1,0) AS top_seller_sort, products_date_added from products_to_categories p2c LEFT JOIN products_description on products_description.products_id=p2c.products_id LEFT JOIN `categories` c on p2c.categories_id=c.categories_id LEFT JOIN products_to_flags p2f on p2c.products_id=p2f.products_id LEFT JOIN `flags` on p2f.flag_id=flags.flag_id left join products p on p.products_id=p2c.products_id left join products_to_categories p2c2 on p2c.products_id=p2c2.products_id left join categories c2 on p2c2.categories_id=c2.categories_id where (c.categories_id=1355 or c.parent_id=1355) and (c2.categories_id=1004 or c2.parent_id=1004) and p.products_status = 1 and p.discontinued=0 group by p2c.products_id order by top_seller_sort DESC, top_mfg_sort DESC