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 `shlgqdwjwcom`.`tww0ogj_goods` AS g LEFT JOIN `shlgqdwjwcom`.`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 ('1','80','89','712','90','714','91','715','95','716','98','720','92','717','94','718','97','93','96','719','81','101','727','750','726','103','99','724','100','725','84','113','114','117','112','115','116','118','85','119','722','121','723','120','123','122','82','106','721','104','728','729','731','732','105','730','86','124','733','125','736','126','737','128','739','127','738','83','109','742','110','740','107','743','111','741','108','744','88','133','734','136','735','134','138','135','137','87','132','130','129','131') OR g.goods_id IN ('218','220','221') ) AND g.supplier_id=0 AND g.brand_id=1 AND g.goods_id IN ('2','3','4','34','35','36','43','44','51','52','57','58','68','69','77','78','84','83','145','146','154','155','156','194','196') AND g.goods_id IN ('47','53','82','97','91','118','120','123','124','127','128','132','152','161') AND g.goods_id IN ('41','42','43','44','45','46') ORDER BY salenum DESC LIMIT 36 |