SQL | SELECT IFNULL(o.num,0) AS salenum, g.goods_id, g.goods_name, g.click_count, g.goods_number, g.goods_name_style, g.market_price, g.is_new, g.is_best, g.is_hot, g.shop_price AS org_price, IFNULL(mp.user_price, g.shop_price * '1') AS shop_price, g.promote_price, g.goods_type, g.promote_start_date, g.promote_end_date, g.goods_brief, g.goods_thumb , g.goods_img FROM `lggemuterc`.`tww0ogj_goods` AS g LEFT JOIN `lggemuterc`.`tww0ogj_member_price` AS mp ON mp.goods_id = g.goods_id AND mp.user_rank = '0' LEFT JOIN (SELECT SUM(og.`goods_number`) AS num,og.goods_id FROM ecs_order_goods AS og, ecs_order_info AS oi WHERE oi.pay_status = 2 AND oi.order_status >= 1 AND oi.order_id = og.order_id GROUP BY og.goods_id) AS o ON o.goods_id = g.goods_id WHERE g.is_on_sale = 1 AND g.is_alone_sale = 1 AND g.is_delete = 0 AND (g.cat_id IN ('85','119','722','121','723','120','123','122') OR g.goods_id IN ('') ) AND g.supplier_id=0 AND g.brand_id=1 AND g.goods_id IN ('82','83','84','85','86','195','196','197','198','214','215','216','217','223') AND g.goods_id IN ('1','2','33','34','41','42','49','50','55','56','67','76','83','137','142','143','144','148','153','194','195','223') AND g.goods_id IN ('3','35','51','43','57','68','77','79','84','86','90','95','101','112','145','149','150','155','164','171','175','180','181','182','183') ORDER BY salenum DESC LIMIT 36 |